Skip to content

SoftAssertions nested in satisfies() or allSatisfy() only output first failing assertion #1353

@maverick1601

Description

@maverick1601

Summary

When using SoftAssertions together with satisfies() or allSatisfy() the additional assertions made in the consumer supplied to these methods are handled differently. In fact, the first failing assertion prevents other in the same consumer to be reported, as expected.

Example

public class MyTest {

  @Test
  public void softAssertionTest() {
    String str = "hello";

    SoftAssertions.assertSoftly(sa -> {
      sa.assertThat(str).satisfies(s -> {
        
        // fails
        sa.assertThat(s).hasSize(2);
        
        // not reported, unless all previous assertions succeed
        sa.assertThat(s).isEmpty();
      });
    });
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions