Aniket
Aniket

Reputation: 11

How to mark script as failed but without aborting execution of current test case in Selenium?

How to mark script as failed but without aborting execution of current test case in Selenium?

@Test
public void testCase() { 
  System.out.println("line 1 printed"); 
  Assert.assertTrue(false);
  System.out.println("i want to execute this line after failure");
}

Upvotes: 1

Views: 95

Answers (1)

Naman
Naman

Reputation: 31868

Using test-ng

SoftAssert softAssert = new SoftAssert();

@Test
public void testCase() { 
    System.out.println("line 1 printed");
    softAssert.assertTrue(true); 
    softAssert.assertEquals("India", "US");
    softAssert.assertTrue(false);
    System.out.println("i want to execute this line after failure");
    softAssert.assertAll();
}

I doubt junit still does not provide such capability.

Upvotes: 1

Related Questions