Skip to content

Instantly share code, notes, and snippets.

@eliasnogueira
Last active March 25, 2023 14:00
Show Gist options
  • Save eliasnogueira/9789c072c83762f02c55ac5b468819e2 to your computer and use it in GitHub Desktop.
Save eliasnogueira/9789c072c83762f02c55ac5b468819e2 to your computer and use it in GitHub Desktop.
SoftAssertion: AssertJ
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.Test;
class SoftAssertionTest {
@Test
void softAssertionUsingAssertJ() {
var person = Person.builder().name("John").phoneNumber(null).age(16).build();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(person.getName()).isNotBlank();
softly.assertThat(person.getPhoneNumber()).isNotNull();
softly.assertThat(person.getAge()).isGreaterThan(18);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment