Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a message in TestNG report (for passed test cases)

TestNG's default emailable report displays exceptions when a test case is failed or an assert message.

But here I want to add a message to the passed Test cases, say some output value in the TestNG report. To be specific:

1. Submit a form in UI.
2. A success message with ID will be displayed.
3. Retrieve that ID using selenium's getText().
4. In the TestNG report, print the above-retrieved ID as "Submitted form ID: {id}".

When the user clicks on the report's passed test cases, I want these messages to be displayed.

Passed Test case Message

like image 580
Bala Avatar asked Nov 25 '25 23:11

Bala


1 Answers

You can display the message in Testng report using Reporter.log if the test case got success then it will print the message as "the value of id is" .

See Below code reference :

@Test
public void testCaseEnabling() {
   System.out.println("I'm Not Ready, please don't execute me");

   Assert.assertEquals(actual, expected);

   int id = 10;

   Reporter.log("the value of id is " + id);
}

Also: import org.testng.Reporter;

like image 128
Nikita Bakshi Avatar answered Nov 27 '25 14:11

Nikita Bakshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!