I use Selenium webdriver 2 with Test-NG. Test-NG gives a nice report when an assertion fails. The customer wishes to see the same report in the case where an assertion passes. Is it possible to do with the default Test-NG reporter?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
TestNG knows nothing about assertions per se. It knows only that the test threw an exception or did not. All of the information that TestNG gets from the assertion comes from the exception thrown by the assertion failure. If an assertion passes, TestNG never knows about it.
On the other hand, you can write your assertion methods that know how to log information, or to write information through TestNG's Reporter object. There may be other ways that an assertion can send information to TestNG, but each of them involves using some form of assertion that knows when and how to report the information.
One possibility is to write your own
One possible implementation:
If your output from Selenium Webdriver is in JUnit format, you can use ReportNG to format it to the way you need it.
If you are not currently outputting the your results in JUnit format, you will need to configure ant to output the reports in XML format (as per this link)
First, I would try to explain to the customer an assertion is a Boolean condition; if the assertion isn't hit then it "passes." Or perhaps ask the customer if they want to "see" what condition each Boolean expression is evaluating and log the condition.
I am not familiar with TestNG, but if they are persistent, then TestNG provides multiple assertion methods including:
This would certainly skew the report and appear to have lots of failures.