News Feed
Jobs Feed
Sections

Recent Jobs

News Archive
Matthew Weir O'Phinney's Blog:
Automating PHPUnit2 with SPL
April 10, 2006 @ 07:10:04

Matthew Weir O'Phinney has been working with PHPUnit and the SPL (Standard PHP Library) in PHP for a bit now, and he's discovered a way to integrate the two to automate the testing procedure.

I've actually come to enjoy the PHPUnit2 style of tests. In the end, I find that my tests are much less verbose than the way I was performing them with phpt, and I tend to test for failure rather than success; failure should be the exception to the rule. The myriad of 'assert' methods make this relatively easy (though some operate in unexpected ways -- try testing assertSame() on two objects that contain PDO handles, for instance).

One thing that was missing for me was an easy way to run all tests in a directory, ala 'pear run-tests'. However, I was initially disappointed. The demonstrated way to do this is to manually require each test file and add the class contained therein to the test suite. Basically, I was going to need to touch the file every time I added a test class to the suite. Bleh!

So, he set about working up his own solution - a regular expresion-based, recursive class that would locate the testing files and perform the specified actions. He shares the solution with a good bit of example code included with the post.

0 comments voice your opinion now!
php automate phpunit2 spl standard library recursive regular expression php automate phpunit2 spl standard library recursive regular expression



Similar Posts

Christian Stocker\'s Blog: PHPUG Switzerland meeting tomorrow evening

Internet Super Hero Blog: MySQL native driver for PHP: mysqlnd-5.0.1-beta available

Codewalkers.com: Book Raffle - Pro PHP XML and Web Services

Robert Peake\'s Blog: Design Patterns, Ajax, and Application Supremacy

Derick Rethans\' Blog: php|tek conference


Community Events









Don't see your event here?
Let us know!


application release database security code package example job cakephp PHP5 book zend ajax zendframework conference developer framework mysql releases PEAR

All content copyright, 2008 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework