您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit-phpunit.xml-phpunit的enforceTimeLimit与defaultTimeLimit属性
发布时间:2021-10-17 17:39:01编辑:雪饮阅读()
enforceTimeLimit 属性
可能值:true 或 false(默认值:false)
此属性配置是否应实施时间限制。
defaultTimeLimit 属性
可能值:整数(默认值:0)
此属性配置默认时间限制(以秒为单位)。
那么对于程序:
MyTest.php:
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class MyTest extends TestCase
{
public function testOne(): void
{
sleep(30);
$this->assertTrue(true);
}
public function testTwo(): void
{
$this->assertTrue(true);
}
public function testThree(): void
{
$this->assertTrue(true);
}
}
不是说默认是0秒的限制,那么我这里是30秒,默认执行如:
[root@localhost tests]# /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.
... 3 / 3 (100%)
Time: 00:30.003, Memory: 18.00 MB
没有什么与时间相关的限制。
但是若phpunit.xml配置如:
<phpunit bootstrap="src/autoload.php" enforceTimeLimit="false" defaultTimeLimit="5">
</phpunit>
再次运行如:
[root@localhost tests]# /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.002, 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:5
OK, but incomplete, skipped, or risky tests!
Tests: 3, Assertions: 2, Risky: 2.
关键字词:phpunit,enforceTimeLimit,defaultTimeLimit
相关文章
- 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
- phpunit-phpunit.xml-phpunit-stopOnFailure
- phpunit-phpunit.xml-phpunit-stopOnError
- phpunit-phpunit.xml-phpunit-printerClass与printerF