我正在使用与jenkins相关的phpunit,我想通过在XML文件中设置配置来跳过某些测试 phpunit.xml
我知道我可以在命令行上使用:
phpunit --filter testStuffThatBrokeAndIOnlyWantToRunThatOneSingleTest
如何将其转换为XML文件,因为<filters>
标记仅用于代码覆盖?
我想进行所有测试 testStuffThatAlwaysBreaks
jst*_*ann 137
跳过破坏或需要继续处理的测试的最快最简单的方法是将以下内容添加到单个单元测试的顶部:
$this->markTestSkipped('must be revisited.');
Run Code Online (Sandbox Code Playgroud)
zer*_*kms 28
如果你可以处理忽略整个文件然后
<?xml version="1.0" encoding="UTF-8"?>
<phpunit>
<testsuites>
<testsuite name="foo">
<directory>./tests/</directory>
<exclude>./tests/path/to/excluded/test.php</exclude>
^-------------
</testsuite>
</testsuites>
</phpunit>
Run Code Online (Sandbox Code Playgroud)
Kon*_*ski 16
有时,基于定义为php代码的自定义条件,跳过特定文件中的所有测试是有用的.您可以使用setUp函数轻松完成此操作,其中makeTestSkipped也可以使用.
protected function setUp()
{
if (your_custom_condition) {
$this->markTestSkipped('all tests in this file are invactive for this server configuration!');
}
}
Run Code Online (Sandbox Code Playgroud)
顺便说一句phpunit 5.2稳定的官方文档建议你应该使用markTestSkipped作为实例方法,而不是静态方法.没有检查定义是否在此过程中发生了变化.
归档时间: |
|
查看次数: |
38704 次 |
最近记录: |