Testng: SoftAssert printing same assertion message for all failed test methods

Created on 4 Feb 2016  ·  3Comments  ·  Source: cbeust/testng

In a Java class I have written around 10 @Test methods. In this class I have created a object(softAssert) for SoftAssert class. In each method at the end of the code I written softAssert.assertAll();
But this line of code printing the first failed assertion message for all the failed methods.
I want to print separate assertion message for each and every method. could any one help me to overcome this.

Most helpful comment

@shivakrishnach31 softAssert object does not clear the list of failed asserts when calling assertAll, so you cannot reuse the same softAssert object in multiple tests. Create a new object at the beginning of every test to fix your problem.

All 3 comments

Hello,

I think stackoverflow or the mailing list is a better start.

BTW,

  • Which TestNG version are you using? Did you try to upgrade it?
  • Could you share a test sample?
  • What is your current output? What is the expected one?

@shivakrishnach31 softAssert object does not clear the list of failed asserts when calling assertAll, so you cannot reuse the same softAssert object in multiple tests. Create a new object at the beginning of every test to fix your problem.

@Mobrockers , It worked now. Thank you.

Was this page helpful?
0 / 5 - 0 ratings