How to continue execution when Assertion is failed

I suggest you to use soft assertions, which are provided in TestNg natively

package automation.tests;

import org.testng.asserts.Assertion;
import org.testng.asserts.SoftAssert;

public class MyTest {
  private Assertion hardAssert = new Assertion();
  private SoftAssert softAssert = new SoftAssert();
}

@Test
public void testForSoftAssertionFailure() {
  softAssert.assertTrue(false);
  softAssert.assertEquals(1, 2);
  softAssert.assertAll();
}

Source: http://rameshbaskar.wordpress.com/2013/09/11/soft-assertions-using-testng/

Leave a Comment