The differences between Assert and Verify are listed below −
|1||Verifies if the specified condition is true and false. If the result is true, the next test step will be executed. In case of false condition, the execution would terminate.||Verifies if the specified condition is true and false. If the result is true, the next test step will be executed. In case of false condition, the execution would still continue.|
|2||In case of false condition, the next text case of the suite will be executed.||In case of false condition, the next test step of the same text case will continue.|
|3||There are two types of assets namely hard and soft asserts.||There are no categories for verification.|
Thus we see there two types of Asserts.
The difference between Soft Assert vs Hard Assert are listed below −
|sl.no.||Hard Assert||Soft Assert|
|1||Throws an exception immediately after the assert fails and carries out with the next test case of the suite.||Does not throw an exception immediately when the assertion fails, collects them and carries out with the next validation.|
|2||This throws an AssertException instantly so handled with a catch block. After suite execution is completed the test is made as PASS.||This accumulates the errors in each @Test execution.|
Object creation for Hard and Soft Assertion.
Assertion HAssert = new Assertion(); SoftAssert SAssert = new SoftAssert();
Soft Assert Examples
SAssert.assertTrue(false); SAssert.assertEquals("Tutorialspoint", "Tutorial");
Hard Assert Examples
HAssert.assertNotEquals("Tutorialspoint", "Tutorial"); HAssert.assertTrue(false);