views:

62

answers:

1

Hi. 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() method 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?

+2  A: 

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.

Anti Veeranna