Skip to content

Instantly share code, notes, and snippets.

@eliasnogueira
Created March 25, 2023 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliasnogueira/869bf9547b83108c615427447f1297bb to your computer and use it in GitHub Desktop.
Save eliasnogueira/869bf9547b83108c615427447f1297bb to your computer and use it in GitHub Desktop.
SoftAssertions: TestNG
public class SoftAssertTestNGTest {
@Test
public void testNGSoftAssertion() {
var person = Person.builder().name("John").phoneNumber(null).age(16).build();
SoftAssert softAssert = new SoftAssert();
softAssert.assertEquals(person.getName(), "John");
softAssert.assertNotNull(person.getPhoneNumber(), "Phone number cannot be null");
softAssert.assertEquals(person.getAge(), 25, "Age should be equal");
softAssert.assertAll();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment