0

I tried ReportNG, but it is not updating the report now & I found that ReportNG is no more used from this answer. I want to create a test report/customize TestNG report to gave to development team. I used Hybrid Framework for creating the project and followed this tutorial.

Community
  • 1
  • 1
Adithya
  • 1,687
  • 3
  • 19
  • 34
  • This is a vague question, what do you mean by `I tried ReportNG, but it is not updating the report now`? – Paras Sep 23 '16 at 07:26
  • @pArAs I generated report using ReportNG as mentoned [link](https://www.seleniumeasy.com/testng-tutorials/configuring-reportng-with-testng-to-generate-html-reports) & got the report as mentioned in it. But that report is generated only once. After some changes I runned my project again but it is still showing the first report generated. – Adithya Sep 23 '16 at 08:31

3 Answers3

1

Yes, you can customize the TestNG reports using Listeners and Reporters. Here is the link of documentation. It is not clear from a question what type of customization you want to do.

But I want to suggest better alternatives for reporting here. There are two most used libraries which generally used with Selenium.

  1. Allure Test Report
  2. Extent Report.

I have not used Allure test reports but it seems to be good and widely used in the community. I have had used Extent Reports in two projects and really happy with it. Anshoo Arora has done the remarkable job. Documentation is very good with lot of example & code snippet. I would highly recommend it.

Amol Chavan
  • 3,835
  • 1
  • 21
  • 32
  • Hi @4M01... I mean I want to create report with custom fields like **Expected Result, Actual result, Result**,etc. – Adithya Sep 23 '16 at 09:46
  • Seems like you came from QTP/UFT background :-) For your requirements, you need to do custom coding. It is not straight away answer as it will depend on a framework that you have to build for the project. But I was able to achieve what you are asking here using Extent Report. Try using extent report and let me know – Amol Chavan Sep 23 '16 at 09:55
  • Okay @4M01. I will try using extent report. I was a manual tester,now switched to automation :-) – Adithya Sep 23 '16 at 10:56
  • in that case just add QAF[https://qmetry.github.io/qaf/latest/download.html] jar either in in dependency management or in class-path libraries it will enable you reporting features with your existing code. – user861594 Sep 23 '16 at 19:42
1

To customize selenium TestNG report, you can use testng listeners.

  1. ITestListener: Log Result/Screenshot on test pass/fail/skip.

  2. IReporter: To generate html report from xml suite results and log.

But as an alternative you can use qaf-reporting.

It provides Detailed Live Reporting (Don`t need to wait for complete execution).

Amit Bhoraniya
  • 621
  • 3
  • 14
  • I agree, QAF reporting is very descriptive and you can get report without waiting for entire execution to get complete. Benefit of QAF reporting over other reporting is: It's live reporting as well as don't introduce out-of-memory issues in case of large test bed. We found many times execution crashed with large number of test case because of out-of-memory while generating report. – user861594 Sep 23 '16 at 19:36
0

I know this is old thread, but these reports can be edited and custom reports can be made like below. I have also explained here how TestHTMLReporter can be edited . And if you would like to know , how index.html report is customized have a look here , where I have explained it in detail

With your customReport You'd have to implement IReporter , extend TestListenerAdapter and override generateReport method if you want to implement a custom TestHTMLReporter . For other reporters you may have to do things a bit differently but the concept will remain the same. You'd achieve custom 'TestHTMLReporter' like below .

Create a CustomReport.java file in your project and copy-paste the whole content of TestHTMLReporter.java , change the name of file in getOutputFile method and it would look like below

public class CustomReport  extends TestListenerAdapter implements IReporter {

     @Override
        public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites,
                                   String outputDirectory) {

        }
   ...
   //paste the content of TestHTMLReporter.java here
   ...
   ...

Make sure all your imports are in place from TestHTMLReporter.java Now, in this file change as per your requirement . For ex: if you'd like to add the end time of each of the test then at the correct place in generateTable method add the below snippet

// Test class
      String testClass = tr.getTestClass().getName();
       long testMillis = tr.getEndMillis();
        String testMillisString = Long.toString(testMillis);
      if (testClass != null) {
        pw.append("<br>").append("Test class Name: ").append(testClass);

         // this line to add end time in ms
        pw.append("<br>").append("End Time(ms): ").append(testMillisString); 
        // Test name
        String testName = tr.getTestName();
        if (testName != null) {
          pw.append(" (").append(testName).append(")");

        }   

Then you'll get like below

enter image description here

Now, You'll get two reports one with default and the other with your file name. The only thing now remains is switching off the default reporting listeners, so you get only one report. For that you can follow this or you may search for solutions. Hope this helps

user1207289
  • 3,060
  • 6
  • 30
  • 66