TestNG Tutorial #3 How to use Hard Assertion in Selenium TestNg
In this video we are going to see what is hard assertion in testng
Hard Assertion
The Default build mechanism of assert is Hard assertion, and it’s stored in org.testng.assert package. We use this type of assertion when our requirement for the test execution should stop immediately is the assertions fail and will throw an assertion error. The test case also marked as failed when a hard condition fails.
Example:
package com.techbeamers.hardassertion; import org.testng.Assert; import org.testng.annotations.Test; public class HardAssertion { String className = “HardAssertion”; @Test public void test_UsingHardAssertion() { Assert.assertTrue(true == true); Assert.assertEquals(“HardAssert”, “HardAssertion”); Assert.assertEquals(className, “HardAssertion”); System.out.println(“Successfully passed!”); } }
... FAILED: test_UsingHardAssertion java.lang.AssertionError: expected [HardAssertion] but found [HardAssert] ...
Comments
Post a Comment