<ac:macro ac:name="note"><ac:parameter ac:name="title">Archived</ac:parameter><ac:rich-text-body>
<p>This proposal has been archived and is no longer under consideration. Most key issues it aimed to solve have solutions in current PHPUnit releases at this time.</p></ac:rich-text-body></ac:macro>
Issues noted during test running and test development:
Cannot run isolated tests - This is important for finding dependancy issues.. also speeds up development time when trying to develop tests.
New test writers are overwhelmed, when there are a lack of standard practices specific to the Zend Framework. Existing tests for components have a higher learning curve than necessary, since some writers add tests to suites and some add suites to suites inconsistently. Also, the current structure and organization increases the risk of changes (e.g. adding a test suite) made to the AllTests file causing adverse effects, like unintentionally undoing others' changes. Tests are getting lost in the shuffle. Currently, 2 test files exists that never get run.
Reasons for ZFTestManager
Ability to isolate unit test suites and unit test tests.
Ability to auto-generate Module's Directory and a stock AllTests.php file with default functionality for autolocating and loading tests.
Simplify unit test writing by reducing the learning curve and by adding Zend Framework conventions to configuraiton and organization.
3. Component Requirements, Constraints, and Acceptance Criteria
Zend_UnitTest will not make increase the complexity or difficulty of writing or using unit tests for ZF components.
Zend_UnitTest will require some very minor changes to the names of existing unit tests and changes to directory organization of the unit tests to adhere to a consistent convention.
Zend_UnitTest will load all tests, and then perform the ones that have been selected.
Zend_UnitTest will support printing a hierarchical list of suites for testing.
Zend_UnitTest will support creating a new suite at specified location.
Zend_UnitTest will allow performing only selected tests, including a specific test, a test suite, and a suite along with its children.
4. Dependencies on Other Framework Components
Zend_Exception
5. Theory of Operation
Using Zend_UnitTest
Writing Tests
@todo
see notes inside generated AllTests.php file inside your Suite directory.
<p>I personally think the biggest problem with writing unit tests for the ZF involve classes with dependencies on database classes (the Zend_Db branch). The setup process in the Zend_Db tests is long and involved, and unnecessary for most scenarios - a much better solutions is to use mocks obviously.<br />
It is still not a straightforward process, and for those new to unit testing might be a deterant to writing tests..</p>
<p>I would very much like if such a unit testing master class has utility functions with such mocks (and partial mocks) prepared beforehand.</p>
<p>Do you really want to add your own component just for filtering by test suite? I think this would be an easy patch for the PHPUnit test suite and you are done, as PHPUnit does support filtering by test case today. I think there is already a ticket open for that in the PHPUnit trac but I can't find it anymore.<br />
Also this is not true isolation. Isolation in the unit testing world means that every test (or even better: every test case) runs with its own scope (so in PHP in it's own process). This feature will be integrated in PHPUnit 4.0.</p>
3 Comments
comments.show.hideJan 27, 2008
Eran Galperin
<p>I personally think the biggest problem with writing unit tests for the ZF involve classes with dependencies on database classes (the Zend_Db branch). The setup process in the Zend_Db tests is long and involved, and unnecessary for most scenarios - a much better solutions is to use mocks obviously.<br />
It is still not a straightforward process, and for those new to unit testing might be a deterant to writing tests..</p>
<p>I would very much like if such a unit testing master class has utility functions with such mocks (and partial mocks) prepared beforehand.</p>
Mar 05, 2008
Lars Strojny
<p>Do you really want to add your own component just for filtering by test suite? I think this would be an easy patch for the PHPUnit test suite and you are done, as PHPUnit does support filtering by test case today. I think there is already a ticket open for that in the PHPUnit trac but I can't find it anymore.<br />
Also this is not true isolation. Isolation in the unit testing world means that every test (or even better: every test case) runs with its own scope (so in PHP in it's own process). This feature will be integrated in PHPUnit 4.0.</p>
Apr 09, 2008
Darby Felton
<p><a class="external-link" href="http://sebastian-bergmann.de/archives/772-Test-Runner-Improvement-in-PHPUnit-3.3.html">http://sebastian-bergmann.de/archives/772-Test-Runner-Improvement-in-PHPUnit-3.3.html</a></p>