Friday, April 24, 2009

Handy hint for unit tests

We've got loads of unit tests. A run takes approximately 20 minutes.

This is because we've got a lot of database interaction, and the re-engineering effort required to go back and mock that all out is immense.

So, what's the best way to make sure you catch problems quickly?

In your AllTests.php, make it a policy to put new test suites at the top, rather than the bottom.


Basically:
    public static function suite() {
$suite = new PHPUnit_Framework_TestSuite();

$suite-<addTestSuite('NewTest');
$suite-<addTestSuite('CoreTest');

return $suite;
}


This is the opposite thinking than "write your most important test cases first", but it helps you find the newest broken features.

Reblog this post [with Zemanta]

No comments: