#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
TestNG & Maven

Viewing Maven Surefire reports

Where Reports Are Generated

After a Maven test run, Surefire generates reports inside target/surefire-reports — including both plain-text (.txt) and XML (.xml) summaries for each test class.

What the Reports Show

  • Number of tests run, passed, failed, and skipped.
  • Execution time per test.
  • Stack traces for any failures.

Why This Matters

These XML reports are the format most CI/CD tools (like Jenkins) read to display test result trends and publish pass/fail dashboards automatically.

Producing and Opening the Reports

Surefire writes its files every time the test phase runs. Start from a clean build so old results from deleted tests do not confuse you:

mvn clean test                       # run all tests, write target/surefire-reports
mvn -Dtest=LoginTest test            # run a single test class
mvn -Dtest=LoginTest#validLogin test # run a single test method

The raw files are not meant to be pretty. For a readable page, use the Surefire Report Plugin, which turns the XML into HTML:

mvn surefire-report:report
# output: target/site/surefire-report.html

mvn surefire-report:report site -DgenerateReports=false
# also generates the CSS and images so the page is styled

If your suite runs on TestNG, the TestNG reporters also place index.html and emailable-report.html inside the same surefire-reports folder. The emailable report is a single file that is easy to attach or share.

Reading an XML Result File

Each test class gets a file named like TEST-com.shop.LoginTest.xml. A shortened example looks like this:

<testsuite name="com.shop.LoginTest" tests="3" failures="1" errors="0" skipped="1" time="2.41">
  <testcase name="validLogin" classname="com.shop.LoginTest" time="0.82"/>
  <testcase name="lockedUser" classname="com.shop.LoginTest" time="0.65">
    <failure message="expected [Locked] but found [Welcome]" type="java.lang.AssertionError">
      ...stack trace...
    </failure>
  </testcase>
  <testcase name="forgotPassword" classname="com.shop.LoginTest" time="0">
    <skipped/>
  </testcase>
</testsuite>

Read it top down. The testsuite line gives the totals. Each testcase without a child element passed. A failure child means an assertion did not hold, while an error child means the test crashed with an unexpected exception, such as a NullPointerException or a timeout. That difference tells you where to look first: failures often point to a product bug, errors often point to the test code or environment.

The time attributes are worth a glance too. A test that suddenly takes much longer than before often hints at a slow environment, a missing wait condition or a performance regression, even when it still passes.

The .txt file for the same class gives a quick summary line and the first part of each stack trace, which is useful when you are reading logs in a terminal.

Using Reports in a CI Pipeline

In Jenkins, the JUnit publisher reads these XML files when you point it at a pattern such as **/target/surefire-reports/*.xml. Jenkins then shows trends across builds and lists newly failing tests. Most other CI tools accept the same format, so no extra conversion is needed.

  • Archive the whole surefire-reports folder as a build artifact so failures can be inspected later.
  • Keep test method names descriptive; they become the labels people see in dashboards.
  • Configure a custom folder with reportsDirectory in the plugin settings only if your pipeline needs it.

Mistakes That Hide Real Results

  • Setting testFailureIgnore to true and then never checking the reports, so a red suite still produces a green build.
  • Reading stale files after skipping clean.
  • Looking for HTML output without running the report plugin.
  • Treating skipped tests as passed; a growing skip count often hides broken setup methods.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course