问题:
1. @runTestsInSeparateProcesses 测试是生效的,但是 @runInSeparateProcesses 似乎不好使
2. 参考文档: http://phpunit.de/manual/3.7/en/appendixes.annotations.html
测试脚本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<?php class M{ public static $name = ''; public static function setname($name) { if (!self::$name) { self::$name = $name; } } } /** * @runTestsInSeparateProcesses */ class A_Test extends PHPUnit_Framework_TestCase { /** * @runInSeparateProcesses * @preserveGlobalState disabled */ public function testA() { M::setname('A'); echo M::$name, "\n"; echo 'pid:'. posix_getpid(),"\n"; $this->assertEquals('A', M::$name); } /** * @runInSeparateProcesses * @preserveGlobalState disabled */ public function testB() { M::setname('B'); echo M::$name, "\n"; echo 'pid:'. posix_getpid(),"\n"; $this->assertEquals('B', M::$name); } } |
注意:使用@runTestsInSeparateProcesses 时,似乎echo的东西是看不到的,这样不利于调试