October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Generate Automated Test Reports with Jenkins

Use a Jenkins Pipeline to publish the result files your test runner creates. This guide covers JUnit XML, existing HTML reports, status behavior, retention, and troubleshooting.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Jenkins can display and track automated test results when your test runner produces report files. In a Declarative Pipeline, run the tests in a stage and publish JUnit-format XML in post { always { ... } }. Jenkins collects the files; it does not run the tests for you or create reports that the test runner did not produce.

Choose a publisher that matches the report your test runner creates

Start by checking the test runner’s output format and file location. The right Jenkins publisher depends on whether you need Jenkins’ test-results interface and history, or a rendered report that your tool already generates.

As an Amazon Associate I earn from qualifying purchases.

Runner output or goal Jenkins approach What to check
JUnit-format XML, including compatible TestNG output Use the junit Pipeline step. Match testResults to the actual XML report directory, and exclude unrelated XML files. The JUnit Pipeline reference documents the step and its options.
A non-JUnit test-report format Use a compatible report publisher plugin, such as the documented xunit or nunit Pipeline steps. Confirm that the installed plugin supports the format and syntax your runner emits. See the xUnit step reference and NUnit step reference.
An HTML report already generated by a test tool Use the HTML Publisher plugin’s publishHTML step. Give it the report directory relative to the workspace, the report file name, and an intentional retention setting. See the HTML Publisher step reference.

JUnit XML is the simplest documented route when the runner can produce compatible files. The Jenkins project explains that it can record and aggregate results provided the runner outputs result files; its tests and artifacts tutorial demonstrates publishing them from a Declarative Pipeline.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Publish JUnit XML from a Declarative Pipeline

Run the project’s test command in a stage, then publish the results in a pipeline-level post section. The always condition lets Jenkins attempt publication even when the test stage fails, which is useful when the runner writes reports for failed tests.

pipeline {
    agent any
    stages {
        stage('Test') {
            steps {
                sh './gradlew check'
            }
        }
    }
    post {
        always {
            junit 'build/reports/**/*.xml'
        }
    }
}

This example uses the pattern shown in Jenkins’ tutorial. Replace ./gradlew check and build/reports/**/*.xml with the command and report path for your project. The pattern is an Ant-style glob; it must match files inside the workspace. Keep it narrow enough to select test-result XML only, not every XML file in the project. The JUnit step reference specifically cautions against including non-report files.

Verify the test runner’s output first

  1. Run the test command locally or in the build and identify where it writes result files.
  2. Check whether it writes reports when tests fail. If it does not, Jenkins cannot publish results for that run merely because the step is in post { always { ... } }.
  3. Compare the observed directory and filenames with the junit glob. Correct the glob rather than broadening it to unrelated XML.
  4. Run the pipeline and open the build’s test results in Jenkins to confirm that the expected tests were found.

Jenkins’ JUnit plugin adds a results UI, failure tracking, and historical trends. Availability and exact behavior can depend on the plugin versions installed on your controller, so check the installed version’s step reference before relying on a setting.

Control missing reports, build status, and retained output

Publishing is also a CI policy decision: decide whether absent results are an error, how reported failures should affect status, and how much test output Jenkins should keep.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Missing or empty result files

The JUnit step’s allowEmptyResults option allows a build to continue without treating missing or empty report files as an error. Use it only when that outcome is expected. Otherwise, it can hide a broken report path or a test tool that produced no results. The default behavior and available syntax should be checked against the installed plugin version in the JUnit step reference.

Failures and build or stage status

By default, reported test failures can mark the build and pipeline stage unstable. The step documents separate controls to skip marking the build or stage unstable. Choose based on the signal your team wants: a report can remain visible even when policy treats test failures differently, but suppressing instability can make a failing test run less obvious in CI. Confirm the precise option names and behavior for the plugin version on your controller.

Standard output and memory use

The JUnit plugin documents stdioRetention modes of all, failed, and none; long output may also be truncated to conserve storage. Retaining extensive output can substantially increase Jenkins memory use. Keep full output when its debugging value warrants that cost; otherwise, retain only what your team needs to diagnose failures.

Publish a generated HTML report

If the test tool already creates an HTML report, install and configure the HTML Publisher plugin, then publish the report directory from the workspace. The JUnit step does not convert arbitrary HTML or another report format into JUnit results.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
post {
    always {
        publishHTML(target: [
            reportDir: 'build/reports/tests/test',
            reportFiles: 'index.html',
            reportName: 'Test Report',
            keepAll: true
        ])
    }
}

Adapt reportDir and reportFiles to the actual output from your tool. The example sets keepAll: true so the report is retained for successful builds as well; choose the retention behavior deliberately. Consult the HTML Publisher Pipeline reference for supported parameters in your installed version.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Optional: attach a web-page screenshot as test evidence

A screenshot can document how a page looked during a test, but it is not a substitute for JUnit XML or a Jenkins test-results publisher. For reproducible evidence, first decide which URL and capture conditions your test should document, and keep the screenshot alongside the test artifacts your workflow retains.

Or skip the browser setup

For a screenshot of a URL, ScreenshotNeo provides a single GET request. It is a screenshot API, not a Jenkins test-report publisher; it does not turn test results into Jenkins trends or HTML reports. See the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -o shot.webp

ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture, with each step configurable. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers indicate the page verdict and billing status. Its MCP server provides screenshot and PDF tools for AI agents, and the free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Learn about ScreenshotNeo or sign up free for 1,000 screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot missing or misleading results

  • No results appear: Check that the runner produced files in the workspace and that the testResults glob matches their actual path and extension.
  • The publisher reports no files: Verify the test stage ran, the report generation is enabled in the runner, and the path is workspace-relative. Avoid enabling allowEmptyResults just to silence an unexpected missing-file condition.
  • Jenkins reads the wrong XML: Narrow the glob so it includes only JUnit-format result files, not unrelated XML such as configuration or other build outputs.
  • Tests fail but no report is published: Confirm whether the runner writes results on failure. The always post condition makes Jenkins attempt publication; it cannot produce files the runner did not create.
  • Build status does not reflect test failures as expected: Review the JUnit step’s build- and stage-instability options and the installed plugin version.
  • Jenkins memory use rises after enabling output retention: Reduce retained standard output from all to failed or none if that still provides enough diagnostic detail.
  • An HTML report is absent: Confirm the HTML Publisher plugin is installed, the directory and report file exist relative to the workspace, and the paths match the tool’s output.

Optional SCM checks integration

The JUnit plugin can publish test results to supported source-control hosting checks when the required integration is installed and configured. For GitHub projects, its documentation names the GitHub Checks Plugin and GitHub App credentials as requirements. This is separate from publishing results in Jenkins; check your controller’s plugin versions and SCM configuration before enabling it. The JUnit plugin page describes the integration and its option to disable checks publishing.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.