Search in sources :

Example 1 with AutoCloseableSoftAssertions

use of org.assertj.core.api.AutoCloseableSoftAssertions in project assertj-core by joel-costigliola.

the class AutoClosableSoftAssertionsLineNumberTest method should_print_line_numbers_of_failed_assertions.

@Test
public void should_print_line_numbers_of_failed_assertions() {
    try {
        AutoCloseableSoftAssertions softly = new AutoCloseableSoftAssertions();
        softly.assertThat(1).isLessThan(0).isLessThan(1);
        softly.close();
        fail("Should not reach here");
    } catch (SoftAssertionError e) {
        assertThat(e).hasMessageContaining(format("1) %n" + "Expecting:%n" + " <1>%n" + "to be less than:%n" + " <0> %n" + "at AutoClosableSoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions(AutoClosableSoftAssertionsLineNumberTest.java:34)%n" + "2) %n" + "Expecting:%n" + " <1>%n" + "to be less than:%n" + " <1> %n" + "at AutoClosableSoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions(AutoClosableSoftAssertionsLineNumberTest.java:35)"));
    }
}
Also used : AutoCloseableSoftAssertions(org.assertj.core.api.AutoCloseableSoftAssertions) SoftAssertionError(org.assertj.core.api.SoftAssertionError) Test(org.junit.Test)

Aggregations

AutoCloseableSoftAssertions (org.assertj.core.api.AutoCloseableSoftAssertions)1 SoftAssertionError (org.assertj.core.api.SoftAssertionError)1 Test (org.junit.Test)1