您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit-phpunit.xml-phpunit-stopOnIncomplete
发布时间:2021-10-13 22:45:17编辑:雪饮阅读()
stopOnIncomplete是干撒子的呢?这里所谓的stopOnIncomplete是配置于phpunit配置文件phpunit.xml的phpunit元素中的属性,若无该属性则其默认值为false。
且让我们看看一个程序:
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->markTestIncomplete('未完成测试1');
}
public function testTwo(): void
{
$this->markTestIncomplete('未完成测试2');
}
public function testThree(): void
{
$this->assertTrue(true);
}
}
这里有两个未完成的测试标记,最后的一个测试是完成的。
那么phpunit.xml:
<phpunit>
</phpunit>
那么运行结果:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.4.3nts\php.exe D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnIncomplete\phpunit-9.5.10.phar -c D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnIncomplete\phpunit.xml D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnIncomplete\MyTest.php
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
II. 3 / 3 (100%)
Time: 00:00.039, Memory: 20.00 MB
OK, but incomplete, skipped, or risky tests!
Tests: 3, Assertions: 1, Incomplete: 2.
可以看到默认情况下3个tests,而断言是1个,未完成测试是2个。
那么假如将stopOnIncomplete设置未true呢?
phpunit.xml:
<phpunit stopOnIncomplete="true">
</phpunit>
其之运行结果:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.4.3nts\php.exe D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnIncomplete\phpunit-9.5.10.phar -c D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnIncomplete\phpunit.xml D:\phpstudy_pro\WWW\phpunitLearning\phpunitLearning-stopOnIncomplete\MyTest.php
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
I
Time: 00:00.003, Memory: 20.00 MB
OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Incomplete: 1.
可以看到运行结果中则是1个tests,相比上面的就少了两个tests,而断言则是0个,,未完成则是1个。
很明显就是说上面的情况下即便某个测试方法未完成,但是仍会继续运行接下来的测试方法,而当stopOnIncomplete设置未true时则就遇到第一个测试方法未完成后接下来就停止运行测试了,不会继续运行接下来的测试方法了。
关键字词: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
- phpunit-phpunit.xml-phpunit-convertDeprecationsToE
- phpunit-phpunit.xml-phpunit-columns