Class JUnitSoftAssertions

All Implemented Interfaces:
AfterAssertionErrorCollected, AssertionErrorCollector, InstanceOfAssertFactories, Java6StandardSoftAssertionsProvider, SoftAssertionsProvider, SoftAssertionsRule, StandardSoftAssertionsProvider, org.junit.rules.TestRule

public class JUnitSoftAssertions extends AbstractSoftAssertions implements StandardSoftAssertionsProvider, SoftAssertionsRule
Same as SoftAssertions, but with the following differences:
First, it's a junit rule, which can be used without having to call assertAll(), example:
 public class SoftlyTest {

    @Rule
    public final JUnitSoftAssertions softly = new JUnitSoftAssertions();

    @Test
    public void testSoftly() throws Exception {
      softly.assertThat(1).isEqualTo(2);
      softly.assertThat(Lists.newArrayList(1, 2)).containsOnly(1, 2);
    }
 }
Second, the failures are recognized by IDE's (like IntelliJ IDEA) which open a comparison window.
  • Constructor Details

    • JUnitSoftAssertions

      public JUnitSoftAssertions()