您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit-phpunit.xml-phpunit-timeoutForLargeTests
发布时间:2021-10-17 18:58:42编辑:雪饮阅读()
timeoutForLargeTests 属性
可能值:整数(默认值:60)
此属性配置标注为 @large 的测试的时间限制(以秒为单位)。
同样的也是要结合enforceTimeLimit为true才好测试。
那么同样看看一个程序:
MyTest.php:
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class MyTest extends TestCase
{
/**
* @large
*/
public function testOne(): void
{
sleep(80);
$this->assertTrue(true);
}
public function testTwo(): void
{
$this->assertTrue(true);
}
public function testThree(): void
{
$this->assertTrue(true);
}
}
这家伙用了large标注了第一个测试方法,且第一个测试方法休眠了80秒。
那么配置文件phpunit.xml:
<phpunit bootstrap="src/autoload.php" enforceTimeLimit="true">
</phpunit>
那么运行结果:
[root@localhost organizing]# /usr/local/php734/bin/php /usr/local/phpunit-9.5.8.phar -c /usr/local/organizing/phpunit.xml /usr/local/organizing/tests/MyTest.php
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
RR. 3 / 3 (100%) .
Time: 01:00.012, Memory: 18.00 MB
There were 2 risky tests:
1) MyTest::testOne
Warning: include(PHPUnit\Composer\Autoload\ClassLoader.php): failed to open stre am: No such file or directory in /usr/local/organizing/src/autoload.php on line 3
Warning: include(): Failed opening 'PHPUnit\Composer\Autoload\ClassLoader.php' f or inclusion (include_path='.:/usr/local/php734/lib/php') in /usr/local/organizi ng/src/autoload.php on line 3
Execution aborted after 60 seconds
2) MyTest::testOne
This test did not perform any assertions
/usr/local/organizing/tests/MyTest.php:8
OK, but incomplete, skipped, or risky tests!
Tests: 3, Assertions: 2, Risky: 2.
那么休眠80秒肯定是超了timeoutForLargeTests默认的60秒的限制的。
那么配置文件phpunit.xml修改如:
<phpunit bootstrap="src/autoload.php" enforceTimeLimit="true" timeoutForLargeTests="5">
</phpunit>
那么再次运行结果如:
[root@localhost organizing]# /usr/local/php734/bin/php /usr/local/phpunit-9.5.8.phar -c /usr/local/organizing/phpunit.xml /usr/local/organizing/tests/MyTest.php
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
RR. 3 / 3 (100%).
Time: 00:05.003, Memory: 18.00 MB
There were 2 risky tests:
1) MyTest::testOne
Warning: include(PHPUnit\Composer\Autoload\ClassLoader.php): failed to open stream: No such file or directory in /usr/local/organizing/src/autoload.php on line 3
Warning: include(): Failed opening 'PHPUnit\Composer\Autoload\ClassLoader.php' for inclusion (include_path='.:/usr/local/php734/lib/php') in /usr/local/organizing/src/autoload.php on line 3
Execution aborted after 5 seconds
2) MyTest::testOne
This test did not perform any assertions
/usr/local/organizing/tests/MyTest.php:8
OK, but incomplete, skipped, or risky tests!
Tests: 3, Assertions: 2, Risky: 2.
那么休眠80秒肯定自然也是超过我们这里新修改的timeoutForLargeTests限制的5秒的。
关键字词:phpunit,timeoutForLargeTests
上一篇:phpunit-phpunit.xml-phpunit-timeoutForMediumTests
下一篇:phpunit-phpunit.xml-phpunit-testSuiteLoaderClass与testSuiteLoaderFile
相关文章
- phpunit-phpunit.xml-phpunit-timeoutForMediumTests
- phpunit-phpunit.xml-phpunit-timeoutForSmallTests
- phpunit-phpunit.xml-phpunit的enforceTimeLimit与def
- phpunit-phpunit.xml-phpunit-beStrictAboutTodoAnnot
- phpunit-phpunit.xml-beStrictAboutTestsThatDoNotTes
- phpunit-phpunit.xml-phpunit-beStrictAboutOutputDur
- phpunit-phpunit.xml-phpunit-stopOnDefect
- phpunit-phpunit.xml-stopOnSkipped
- phpunit-phpunit.xml-phpunit-stopOnRisky
- phpunit-phpunit.xml-phpunit-stopOnIncomplete