Reputation: 161
My code is like this:
@BeforeMethod
public void beforeMethod() {
url= GetUrlBasedOnParameter(parameter);
if(is.empty(url)) {
SkipTest();
} else {
ExecuteTest();
}
}
What condition can I use in SkipTest()
so that without adding any additional parameters in @Test
annotation, I can skip the test?
FYI: I tried driver.quit()
and driver.close()
but the @Test
annotation is still executed.
Upvotes: 1
Views: 749
Reputation: 8394
In TestNG, you can use
throw new SkipException("message");
So, your @BeforeMethod
could look like
@BeforeMethod
public void beforeMethod() {
url= GetUrlBasedOnParameter(parameter);
if(is.empty(url)) {
throw new SkipException("URL is empty");
} else {
ExecuteTest();
}
}
Upvotes: 1