Should I use CodeIgniter's Unit Testing Class or PHPUnit/TOAST?
I'm looking for a good unit testing for my web development. I'm using CodeIgniter开发者_运维知识库 for PHP, and I found this class on CodeIgniter's documentation, so here is my doubt:
Should I use 'Unit Testing Class' to test my code, or is going to be better to use PHPUnit or TOAST? Which is better and why?
I hope someone experienced can help me. Thanks!
In my opinion, I think it's better to use the standard PHPUnit for unit-testing.
Aside from that it has many nice features, your tests will be more consistent and it wont depend on CakePHP's unit testing class.
If in the future you decide that CakePHP does not suite your needs, you'll lose your unit tests. (or lets say, you'll have to migrate them, which is time)
If you are testing code, that depends on CakePHP(Controller, Model, etc), there's no problem to use CakePHP's tests, but for any other case, i think you should bet on the more-popular unit testing suite that can be used in every project (PHPUnit)
Happy testing :)
I haven't done any test with codeignitor's build in unit test class. but it looks like that this class provide only very simple assertion function (maybe it is because of the pursuit of lightweight) and the worst thing is, you have to mess up the testing code with your production code.
For unit test, it offers much more assertion functions, more features: like code coverage, selenium RC...etc. so it can extend your ability to ensure code quality. one more benefit is, it does not depend on any of your framework code, so you can easily migrate.
Unit Testing Class is quite simple test suite. If you need full unit testing of your code use PHPUnit.
Codeigniter has its own unit testing feature
Please go to http://codeigniter.com/user_guide/libraries/unit_testing.html
Thanks
精彩评论