David Ruan
David Ruan

Reputation: 794

How to skip a test and not fail it

In the middle of the test, if the condition of the test is not satisfied, how can I skip the test without failing it.

I try to throw an exception and it is marked as failed.

Upvotes: 1

Views: 1543

Answers (2)

I think you can use some thing like

try {

 ///some process

try {
 ///your middle test 
}catch (excetion e){
}

}catch (excetion e){
}

If the middle test is failed the rest will work

Upvotes: 0

Moe Ghafari
Moe Ghafari

Reputation: 2267

You will need to use the assume:

org.junit.Assume.assumeTrue(condition());

If this fails your test will be ignored. I recommend doing this assume in your @Before method

Hope this helps

Upvotes: 3

Related Questions