如何使PHPUnit在风险测试中失败 [英] How to make PHPUnit fail on risky tests
问题描述
如果一项或多项测试被认为具有风险,我希望PHPUnit 失败.其实:
I want PHPUnit to fail if one or more test is considered as risky. Actually:
PHPUnit 5.3.4 by Sebastian Bergmann and contributors.
..RRR.. 7 / 7 (100%)
Time: 2.83 seconds, Memory: 26.00Mb
OK, but incomplete, skipped, or risky tests!
Tests: 7, Assertions: 137, Risky: 3.
它显示确定,但不完整",因此我的测试没有失败(可以在连续交付的情况下发货).有什么办法可以拥有失败"状态?我希望我的测试全局状态被认为在风险测试中未通过,不知道是否有可能.
It says "OK, but incomplete", so my tests did not fail (and can be shipped in case of continous delivery). Is there any way to have a "fail" status? I want my test global status considered as failed on risky test, don't know if it's possible.
推荐答案
有一个--stop-on-risky
选项可以从命令行启用,也可以在phpunit.xml
中配置.
There is a --stop-on-risky
option that can be enabled from the command line or configured in the phpunit.xml
.
问题是运行过程不会执行所有测试.我不知道将风险测试视为失败的直接方法.
The problem with this is that the run process wont execute all the tests. I'm not aware of a direct way of considering risky tests as failed.
您想要获得的行为已被提出但未被接受,因此不要期望得到实现:
The behaviour you want to obtain was proposed but not accepted, so don't expect to be implemented:
https://github.com/sebastianbergmann/phpunit/issues/1612
这篇关于如何使PHPUnit在风险测试中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!