Can an Assertion be set up such that even if it fails, the test will continue?


I have many points in my tests where I want to validate something, but the test should not fail and exit if that validation fails. Is it possible to tell Webtestit to continue the test if certain assertions don’t pass?


Hello @ohrnsk!
Yes, of course. You could accomplish this in two ways:

  1. Use try/catch block with your assertions and catch the assertion exception, for example
        try {
            Assert.assertEquals(actual, expected);

        } catch (AssertionError e) {
            System.out.println("Assertion failed!");
  1. Use the Soft Assert TestNG method:
// Instantiate SoftAssert 
SoftAssert softAssertion= new SoftAssert();

// Call the SoftAssert method
softAssertion.assertEquals(actual, expected);


In both cases, the test execution will continue even if the assertion would fail. In the first case, the exception is caught, and the message is printed to the log.
In the second case, SoftAssert will allow the execution of the rest of your test steps even after the failed assertion, and softAssertion.assertAll() method will collate the result of all the assertions and in case of any failure mark the whole test as failed.
Find out more about SoftAssert here.

closed #3