Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Can we skip a test case conditionally?

Category: TestNG

Using SkipException, we can conditionally skip a test case. On throwing the skipException, the test method is marked as skipped in the test execution report and any statement after throwing the exception will not get executed.

@Test
public void testMethod(){
if(conditionToCheckForSkippingTest)
throw new SkipException(“Skipping the test”);
//test logic
}

Leave a Reply

Your email address will not be published. Required fields are marked *