JUnit HTML Report

Filed Under: JUnit

When we configure maven-surefire-plugin to run our JUnit tests, it generates surefire-reports directory. This directory contains a txt file and an XML file for every test class. However, reading these files is not easy and it’s also not easily explainable to a non-techie person.

JUnit HTML Report

We can use maven-surefire-report-plugin plugin to generate HTML based reports for our JUnit tests. This report can be exported and shared with the team. It’s also an easy way to understand how your tests went through, especially when you integrate them with CI tools like Jenkins.

There are two steps to generate JUnit HTML report from our maven project.

  1. Add maven-surefire-report-plugin to pom.xml reporting element.
  2. Run mvn site command from the terminal. It will generate HTML reports in target/site directory.

Open the surefire-report.html file in the browser. You will get an output like below image, it’s from my JUnit Examples project.

JUnit HTML Reports using Maven Surefire Report Plugin

Some of the useful information we get from JUnit HTML report are:

  • Test Packages and Classes
  • Test Methods names from specific classes
  • Failure tests or skipped tests with reason
  • Execution time taken by each method


TestNG supports built-in HTML report generation whereas JUnit HTML reports are generated by maven surefire plugin and we have to execute an additional command for it. However, JUnit HTML reports look much better when compared to TestNG HTML reports.


  1. nags says:

    I didn’t see any html reports generated. I used the https://raw.githubusercontent.com/journaldev/journaldev/master/JUnit5-Example/pom.xml

    wondering what is missing 馃檨

  2. Amado Saladino says:

    In case of any failure, site goal will not run, this method is unreliable

  3. Karim Djaafar says:

    Good article but we need to add the following lines in the pom.xml in order to avoid some compilation problems due to the obsolete pugin site:



Comments are closed.

Generic selectors
Exact matches only
Search in title
Search in content