开发者

Extending testcases from PHPUnit_Framework_TestCase instead of Zend_Test_PhpUnit_ControllerTestCase in a Zend project

I'm using Zend Framework in one of my projects and I'm using PHPUnit for unit testing. I know that Zend_Test_PhpUnit_ControllerTestCase class is good for testing controllers with its dispatch() me开发者_运维百科thod and all. But I also have a few simple classes like ones used for some calculations and so on. These classes do not require the entire Zend application to be bootstrapped and fired up to be tested.

So my question is should I extend my testcases from PHPUnit_Framework_TestCase class directly? Would it be a good development practice? Is it any good performance-wise?


One of the goals for writing unit tests should to be keep the code as clear, short and concise as possible. Tests are code too and need to be maintained in the future.

There is absolutely nothing wrong with using PHPUnit_Framework_TestCase directly for testing. Firstly because the whole testing framework is built upon it anyway. And secondly - since your simple classes do not contain controller logic, why would you include controller testing helpers then?

As for performance - I doubt the difference is even noticeable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜