Verisoft Wiki

Soft assertions are types of assertions, in which the test execution does not stop if the test does not meet the assertion condition. The remaining tests are executed. If a test does not meet the assertion condition, at the method call assertAll it will fail.

Here is an example of using soft assertions:

@Test
public void assertAllMultipleFailuresAssertionErrorWithAllFailures(){
    SoftAsserts softAsserts = new SoftAsserts();
    
    boolean condition1 = false;
    boolean condition2 = false;
    
    softAsserts.assertTrue(condition1, "Condition 1 should be true");
    softAsserts.assertTrue(condition2, "Condition 2 should be true");
    
    softAsserts.assertAll();
}

It the above example, two conditions are false and tested to be true. Both will fail, however the test execution is not halted until the softAsserts.assertAll(); is called