Skip to content

Instantly share code, notes, and snippets.

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
What would you like to do?
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 {
void softAssertionUsingJUnit5() {
var person = Person.builder().name("John").phoneNumber(null).age(16).build();
() -> 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