SoftAssertions: JUnit 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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