TestNG Reports

  

What Are TestNG Reports?

TestNG Reports are automatically generated HTML/XML reports that give detailed feedback about:

  • Passed tests

  • Failed tests

  • Skipped tests

  • Execution time

  • Grouped tests

  • Exceptions and stack traces

These reports help QA teams and developers track the status of test executions and debug issues faster.


Types of TestNG Reports

By default, TestNG generates the following reports in the test-output folder after you run your tests:

Report FileFormatDescription
index.htmlHTMLSummary report of all suites
emailable-report.htmlHTMLEmail-friendly, basic summary report
testng-results.xmlXMLMachine-readable report for CI tools
testng-failed.xmlXMLSuite file with only failed tests
Default suite/Default test.htmlHTMLDetailed class-level execution report


Where Are Reports Stored?

Reports are saved automatically in the test-output directory in your project after running your suite.


Example Java code of TestNG script to generate Reports

import org.testng.Assert;
import org.testng.annotations.Test;

public class TestReportExample {

    @Test
    public void testPass() {
        System.out.println("This test will PASS");
        Assert.assertTrue(true);
    }

    @Test
    public void testFail() {
        System.out.println("This test will FAIL");
        Assert.assertTrue(false, "Intentionally failing the test");
    }

    @Test
    public void testSkip() {
        System.out.println("This test will be SKIPPED");
        throw new SkipException("Skipping this test intentionally");
    }
}


 
Create testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="ReportSuite">
  <test name="ReportingTest">
    <classes>
      <class name="TestReportExample"/>
    </classes>
  </test>
</suite>


Run the Test

  1. Right-click testng.xml in Eclipse/IntelliJ

  2. Choose Run As > TestNG Suite

  3. After execution, go to the test-output/ folder in your project

  4. Open index.html or emailable-report.html in your browser