如何通过参数 运行 不同的测试服?
How to run different test suits by parameter?
我有一些代码 运行ning selenium 测试。我使用带有 @RunWith 和 @Suite 注释的 Junit 4.12 测试 运行。
到目前为止,我 运行 在一台机器上使用 3 个单独的测试来测试套件。
我现在必须 运行 我在多台机器上进行测试,有些机器是在没有 GPU 的情况下设置的。
由于我的一项测试依赖于 GPU,因此我希望能够在 运行 没有 GPU 的机器上自动省略测试。
这是我目前的代码 -
@RunWith(Suite.class)
@Suite.SuiteClasses({
Test1_With_GPU.class,
Test2_Without_GPU.class,
Test3_Without_GPU.class
})
有什么办法可以再换一套花色:
@Suite.SuiteClasses({
Test2_Without_GPU.class,
Test3_Without_GPU.class
})
和运行套件根据pom.xml
中的systemProperties
<systemProperties>
<property>
<name>runWithGPU</name>
<value>${runWithGPU}</value>
</property>
</systemProperties>
所以 runWithGPU==True
我会 运行 第一套房,但是 runWithGPU==False
我会 运行 第二套房?
我通过在我的代码中添加以下行找到了跳过测试的方法:
public void test() {
assumeThat(System.getProperty("RUN_TEST_1"), CoreMatchers.is("True"));
// rest of code here
}
现在我的代码 运行 跳过测试,如果我 运行 mvn test -DRUN_TEST_1=False
.
希望这对以后的人有所帮助。
我有一些代码 运行ning selenium 测试。我使用带有 @RunWith 和 @Suite 注释的 Junit 4.12 测试 运行。 到目前为止,我 运行 在一台机器上使用 3 个单独的测试来测试套件。 我现在必须 运行 我在多台机器上进行测试,有些机器是在没有 GPU 的情况下设置的。 由于我的一项测试依赖于 GPU,因此我希望能够在 运行 没有 GPU 的机器上自动省略测试。
这是我目前的代码 -
@RunWith(Suite.class)
@Suite.SuiteClasses({
Test1_With_GPU.class,
Test2_Without_GPU.class,
Test3_Without_GPU.class
})
有什么办法可以再换一套花色:
@Suite.SuiteClasses({
Test2_Without_GPU.class,
Test3_Without_GPU.class
})
和运行套件根据pom.xml
中的systemProperties<systemProperties>
<property>
<name>runWithGPU</name>
<value>${runWithGPU}</value>
</property>
</systemProperties>
所以 runWithGPU==True
我会 运行 第一套房,但是 runWithGPU==False
我会 运行 第二套房?
我通过在我的代码中添加以下行找到了跳过测试的方法:
public void test() {
assumeThat(System.getProperty("RUN_TEST_1"), CoreMatchers.is("True"));
// rest of code here
}
现在我的代码 运行 跳过测试,如果我 运行 mvn test -DRUN_TEST_1=False
.
希望这对以后的人有所帮助。