Friday, 15 August 2014

Skip TestNG test based on a condition

Sometimes you might want to skip tests based on a condition. Following snippet shows a simple way to do it by throwing a testngSkipException. This integrates seamlessly with test reports and skipped tests are counted displayed correctly in it.

//....code snippet.....
// Filter out bad tests
for (String c : conditions) {
if(c.matches("some condition 1") || c.matches("some other condition")){
throw new org.testngSkipException(c);
}
}
//....code snippet.....

No comments:

Post a Comment