Selenium Automation:根据@BeforeMethod 中的条件跳过测试执行
Selenium Automation: Skip execution of test based on a condition in @BeforeMethod
我的代码是这样的:
@BeforeMethod
public void beforeMethod() {
url= GetUrlBasedOnParameter(parameter);
if(is.empty(url)) {
SkipTest();
} else {
ExecuteTest();
}
}
我可以在 SkipTest()
中使用什么条件,以便在 @Test
注释中不添加任何额外参数,我可以跳过测试?
仅供参考:我尝试了 driver.quit()
和 driver.close()
,但 @Test
注释仍在执行。
在 TestNG 中,您可以使用
throw new SkipException("message");
所以,你的 @BeforeMethod
可能看起来像
@BeforeMethod
public void beforeMethod() {
url= GetUrlBasedOnParameter(parameter);
if(is.empty(url)) {
throw new SkipException("URL is empty");
} else {
ExecuteTest();
}
}
我的代码是这样的:
@BeforeMethod
public void beforeMethod() {
url= GetUrlBasedOnParameter(parameter);
if(is.empty(url)) {
SkipTest();
} else {
ExecuteTest();
}
}
我可以在 SkipTest()
中使用什么条件,以便在 @Test
注释中不添加任何额外参数,我可以跳过测试?
仅供参考:我尝试了 driver.quit()
和 driver.close()
,但 @Test
注释仍在执行。
在 TestNG 中,您可以使用
throw new SkipException("message");
所以,你的 @BeforeMethod
可能看起来像
@BeforeMethod
public void beforeMethod() {
url= GetUrlBasedOnParameter(parameter);
if(is.empty(url)) {
throw new SkipException("URL is empty");
} else {
ExecuteTest();
}
}