您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit-phpunit.xml-stopOnSkipped
发布时间:2021-10-15 22:46:30编辑:雪饮阅读()
stopOnSkipped是一个什么配置呢?
这里所谓的stopOnSkipped配置是在phpunit的phpunit.xml配置文件中phpunit元素的一个属性。
让我们先看看如下程序的执行结果:
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->markTestSkipped(
'The MySQLi extension is not available.'
);
}
public function testTwo(): void
{
$this->markTestSkipped(
'The MySQLi extension is not available.'
);
}
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-stopOnSkipped\phpunit-9.5.10.phar -c D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnSkipped\phpunit.xml D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnSkipped\MyTest.php
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
SS. 3 / 3 (100%)
Time: 00:00.004, Memory: 20.00 MB
OK, but incomplete, skipped, or risky tests!
Tests: 3, Assertions: 1, Skipped: 2.
那么同样的这里所用到的配置文件phpunit.xml:
<phpunit>
</phpunit>
那么假如说这里将stopOnSkipped属性配置为true:
<phpunit stopOnSkipped="true">
</phpunit>
因为stopOnSkipped属性默认是false。
那么接下来再看看执行的结果如何:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.4.3nts\php.exe D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnSkipped\phpunit-9.5.10.phar -c D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnSkipped\phpunit.xml D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnSkipped\MyTest.php
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
S
Time: 00:00.002, Memory: 20.00 MB
OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Skipped: 1.
和上面修改配置之前,可以看到测试结果中skipped的跳数少了,很明显的:
stopOnRisky 属性
可能值:true 或 false(默认值:false)
此属性配置是否应当在第一个以“有风险(risky)”状态结束的测试之后停止测试套件的执行。
也就是说stopOnRisky属性决定了这里第一个有风险的测试之后是否继续运行,若stopOnRisky配置为true,则不继续运行,默认是false,所以继续运行测试,所以就看到了两个skipped,因为第二个测试方法也是有跳过的。
关键字词:phpunit,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
- phpunit-phpunt.xml-phpunit-convertErrorsToExceptio