0
votes

I am new to the Automation testing and I am using softAssert(), I am creating one user For example: "User1" and when I search for the same user that is "User1",then it shows result as "No Result Found". So ideally my test case should get break but it still get passed.I print the actual and expected value both are different but it is still passing the test case.Please help me out. My code is:

softAssert.assertEquals(lookupTypeRecordFound.getText(), looupTypeName);

1
do you know how softAssert works? Maybe reading this softwaretestingmaterial.com/soft-assert would clear up something for you. - Stultuske
@Stultuske I know how softAssert works but my main concern is when string is not match ideally it should get failed but it is still passing. For example: softAssert.assertEquals("String1","String2") this should get failed. Hope my question makes sense, Thanks in Advance - ajinkya
Yes, but that is because that's not how softAssert works. it doesn't throw an Exception, it stores it in a list. You should assert on that list being empty or something similar - Stultuske

1 Answers

1
votes

The thing you are missing - to fail the test on any SoftAssert errors, you need to add this to the end of your test method:

softAssert.assertAll();

To break test execution immediately, you can use the "hard" assert, namely:

Assert.assertEquals(lookupTypeRecordFound.getText(), looupTypeName);