Unit testing 排除TestNG中@BeforeMethod中的某些方法
在我的测试中,我想在这些方法真正发生之前调用它们Unit testing 排除TestNG中@BeforeMethod中的某些方法,unit-testing,testng,Unit Testing,Testng,在我的测试中,我想在这些方法真正发生之前调用它们 @BeforeMethod public void setUpMethod() throws Exception { } 除了一个给定的测试方法 例如,我想先测试delete(),然后在测试方法开始时系统地应用它 因此,我想提出如下意见: @BeforeMethod("all methods except delete()") public void setUpMethod() throws Exception { delete();
@BeforeMethod
public void setUpMethod() throws Exception {
}
除了一个给定的测试方法
例如,我想先测试delete(),然后在测试方法开始时系统地应用它
因此,我想提出如下意见:
@BeforeMethod("all methods except delete()")
public void setUpMethod() throws Exception {
delete();
}
一种方法是将delete()放入一个组中,例如 @测试(group=“excludeBef”) 现在,在testngxml中,设置两个测试,一个测试只包含这个组,在这种情况下,它不会为这个组运行before方法,另一个测试排除这个组
<test verbose="2" name="Default test" >
<groups>
<run>
<include name="excludeBef"></include>
</run>
</groups>
<classes..go here>
</test>
<test>
<groups> - exclude the group </group>
<classes ..go here>
-排除该组