Skip to content

Instantly share code, notes, and snippets.

Embed
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 {
@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