12
Sep

SoftAsserts in TestNG

		SoftAssert sa = new SoftAssert();

		int result = 1 + 2;
		// we need to use that object when we are calling them
		sa.assertEquals(result, 2);
		System.out.println("\nLine after assert 1");
		sa.assertEquals(result, 3);
		System.out.println("\nLine after assert 2");
		sa.assertTrue(false);
		System.out.println("\nLine after assert 3");
		// the asserts used till now will not throw any exception if they fail. The
		// @Test will not fail either.
		// If you need the test method to fail at the end, showing all exceptions, you
		// need to use assertAll()
		sa.assertAll();