ttokic
ttokic

Reputation: 116

Skip TestNg test in runtime

I don't have a lot of experiences with TestNG, so do you know hot to skip or ignore some tests in Java Runtime. My idea is to write @Before-annotiation test and if it fails the incoming test will be ignored.

I tried to use JUnit with assume method, but I don't prefer it because if "before-test" fails the incoming test is highlighted as passed and it's not a reliable solution because it has ambiguous meaning.

So if you have any experiences with TestNG, please help I would be grateful.

Upvotes: 5

Views: 6320

Answers (2)

Rohit
Rohit

Reputation: 119

You can skip test by throwing SkipException

throw new SkipException("Skip this");

Upvotes: 9

Ilya
Ilya

Reputation: 29703

You need group of tests. Annotation @Test with next params
dependOnGroup or
dependsOnMethods

e.g.

@Test
public void verifyConfig() {
//verify some test config parameters
}

@Test(dependsOnMethods={"verifyConfig"})
public void dotest(){
//Actual test
}

Upvotes: 1

Related Questions