Skip to content

Instantly share code, notes, and snippets.

@eliasnogueira
Last active March 26, 2023 11:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save eliasnogueira/18d273460d7a982af7cb9053057819b2 to your computer and use it in GitHub Desktop.
SoftAssertions: JUnit 5
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
class SoftAssertionJunit5Test {
@Test
void softAssertionUsingJUnit5() {
var person = Person.builder().name("John").phoneNumber(null).age(16).build();
assertAll("person",
() -> assertNotNull(person.getName(), "Name must not be null"),
() -> assertNotNull(person.getPhoneNumber(), "Phone number should not be null"),
() -> assertEquals(18., person.getAge(), "Age must be 18")
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment