Is there any difference between Soft assert and Verify?
I am well aware that Verify is implemented using SoftAssert class. And when any of the methods fails, both the above keywords will continue the execution.
Is there a specific difference while using soft assert and verify in TestNG framework?
Assert: If the assert condition is true then the program control will execute the next test step but if the condition is false, the execution will stop and further test step will not be executed. whereas, Verify: There won't be any halt in the test execution even though the verify condition is true or false.
Soft asserts are the asserts which continue the execution even after the Assert condition fails. Soft asserts are mainly used to verify certain test conditions in the code. It is used in a case when the passing of one test condition is not necessary to execute the upcoming tests.
Soft Assertions are the type of assertions that do not throw an exception immediately when an assertion fails. Therefore, all steps and soft assertions in the automated test will execute before failing the test.
Verify is a class, used for comparing expected and actual test results as assert class does, but when it fails it will not stop the test execution, it continues to run the test cases. In Selenium Web Driver it is achieved using Soft Assertion.
If we are talking about functionality then there is no such difference. But I would suggest you using "soft assert" instead of "verify" because it gives you better visibility in terms of coding and reporting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With