Programmer
Programmer

Reputation: 475

How to generate testNG report with assert pass or fail information

Hi I have a testNG class with Assert.assertTrue(true, "PASS"); and Assert.assertFalse(false, "FAIL"); statements. After the execution I am not able to find these PASS and FAIL result in the HTML report generated. I googled and found these may not be displayed in the report generated. So my question is, if testNG report does not provide this feature, is there any other reporting with which I can find these data after execution of my test in my report?

Upvotes: 1

Views: 6418

Answers (3)

Sharfi
Sharfi

Reputation: 365

If you want to fail the same Test case then you need to add Assert.fail() in your test case. Then it will display as fail in your report.

Upvotes: 0

Programmer
Programmer

Reputation: 475

To log the information from the script to the HTML report we must use the class org.testng.Reporter. Now to print the data to the report we must use Reporter.log("PASS/FAIL");.

Upvotes: 2

murali selenium
murali selenium

Reputation: 3927

if you use Assert.assertTrue(condition, message); then when the condition is fail means it does not returns true, then the message is printed. So if assertion is true or pass then message is not printed.

To customize the HTML reports in TestNG, you need to use TestNG Listeners. below link will help you http://testng.org/doc/documentation-main.html#logging-reporters

Let me know, if it is what you looking for.

Thank You, Murali

Upvotes: 1

Related Questions