News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthew Turland's Blog:
Process Isolation in PHPUnit
August 20, 2010 @ 09:26:41

Matthew Turland has a new post today about isolating tests in PHPUnit testing to try to avoid overlap in the resources each needs.

One requirement of the test suite was that some test methods had to be run in a separate process since class declarations reside in the global scope and persist until the process terminates. So, I slapped a @runInSeparateProcess annotation in the docblock of a test method with that requirement, ran the test suite' and watched that test method fail because the class was still being declared.

After come close examination of his code and the PHPUnit source, he found the issue - a misunderstanding of how the preserveGlobalState property should be set. For it to work as he wanted, it needed to be set before the run() method was called for test execution. To correct the issue in his code, he overrides the run() method to set the value and call the parent.

0 comments voice your opinion now!
process isolation phpunit unittest preserveglobalstate


blog comments powered by Disqus

Similar Posts

PHPMaster.com: Bulletproofing Database Interactions with PHPUnit's Database Extension

Web Builder Zone: PHPUnit 3.5: easier asserting and mocking

Chris Hartjes' Blog: Testing Web Services in Zend Framework 1.x

DZone.com: PHPUnit vs. Phake cheatsheet

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 8)


Community Events

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


series community extension release example unittest version opinion podcast php7 introduction framework api interview laravel5 library laravel language voicesoftheelephpant conference

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