您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit-phpunit.xml-phpunit-stopOnDefect
发布时间:2021-10-15 22:58:01编辑:雪饮阅读()
stopOnDefect 属性
可能值:true 或 false(默认值:false)
此属性配置是否应当在第一个以“错误(error)”、“失败(failure)”,“有风险(risky)”或“警告(warning)”状态结束的测试之后停止测试套件的执行。
这里以一个有多处failure的程序为例进行默认执行:
MyTest.php:
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\TextUI\ResultPrinter;
use PHPUnit\TextUI\DefaultResultPrinter;
final class MyTest extends TestCase
{
public function testOne(): void
{
$this->assertTrue(false);
}
public function testTwo(): void
{
$this->assertTrue(false);
}
public function testThree(): void
{
$this->assertTrue(true);
}
}
其之运行结果:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.4.3nts\php.exe D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnDefect\phpunit-9.5.10.phar -c D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnDefect\phpunit.xml D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnDefect\MyTest.php
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
FF. 3 / 3 (100%)
Time: 00:00.004, Memory: 20.00 MB
There were 2 failures:
1) MyTest::testOne
Failed asserting that false is true.
D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnDefect\MyTest.php:9
2) MyTest::testTwo
Failed asserting that false is true.
D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnDefect\MyTest.php:13
FAILURES!
Tests: 3, Assertions: 3, Failures: 2.
可以看到其两个failure状态都有被运行。
那么假如配置文件配置了stopOnDefect为true:
phpunit.xml:
<phpunit stopOnDefect="true">
</phpunit>
当再次运行时候:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.4.3nts\php.exe D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnDefect\phpunit-9.5.10.phar -c D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnDefect\phpunit.xml D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnDefect\MyTest.php
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
F
Time: 00:00.004, Memory: 20.00 MB
There was 1 failure:
1) MyTest::testOne
Failed asserting that false is true.
D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnDefect\MyTest.php:9
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
这次运行结果中可见只运行了一次failure,然后后面就中断运行其它测试方法了。
关键字词:phpunit,stopOnDefect
上一篇:phpunit-phpunit.xml-stopOnSkipped
下一篇:phpunit-phpunit.xml-phpunit-beStrictAboutOutputDuringTests
相关文章
- 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
- phpunit-phpunit.xml-phpunit-processIsolation
- phpunit-phpunit.xml-phpunit-forceCoversAnnotation
- phpunit-phpunit.xml-phpunit-convertWarningsToExcep
- phpunit-phpunit.xml-phpunit-convertNoticesToExcept