Test reporting in Pipelines

We've made it easier to quickly identify failed tests in your build. Test reporting will be automatically enabled in your pipeline when it detects xUnit/JUnit compatible test results which include a fail.

How test reporting works

If your build step generates test results, pipelines will automatically detect and show any failures in the web interface. This works with most XML xUnit-compatible test reports (but does not include xUnit.net), regardless of the language they are written in. 

Any user with read access to the repository can view the test results in the pipelines log panel. If failed test results are found, the log view will change to highlight the failed tests, showing the reason and the stack-trace if present. The full log view is also available using the Build tab.

The Tests tab will only show if you have failed tests to review.

Failed test limits

  • Only the first 100 failed test results are displayed.

  • Each test case field, such as stacktrace, has a 2,000 character max limit.

Configuring test reporting

To enable test reporting, make sure that build test reports are generated in one of the supported default locations (with a directory depth of 3 levels):

1 ./**/surefire-reports/**/*.xml
1 ./**/failsafe-reports/**/*.xml
1 ./**/test-results/**/*.xml
1 ./**/test-reports/**/*.xml

The test report file scanner will begin searching from the base directory of your build: /opt/atlassian/pipelines/agent/build

Configuring test runners

Maven Surefire / Failsafe plugins

For Maven build jobs, no special configuration is required if you are using Maven Surefire Plugin or Maven Failsafe Plugin. The reports are automatically generated when the unit or integration maven test goals are executed.


For Gradle builds, test reports are automatically generated in XML xUnit-compatible format. No special configuration is required as, by default, Gradle generates the test results in one of the default locations.


For PHPUnit test reports, you should explicitly specify the --log-junit parameter to generate the test reports output to a particular location.


1 2 3 4 5 6 7 8 9 10 image: php:7.1.1 pipelines: default: - step: script: - apt-get update && apt-get install -y unzip - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - composer require phpunit/phpunit - vendor/bin/phpunit --log-junit ./test-reports/junit.xml

Mocha for Node.js

For Mocha test framework, you can use the mocha-junit-reporter and configure the output file where the test report will be generated. 

1 2 3 4 5 6 7 image: node:10.15.0 pipelines: default: - step: script: - npm install mocha mocha-junit-reporter --save-dev - mocha test --reporter mocha-junit-reporter --reporter-options mochaFile=./test-reports/junit.xml

Unittest for Python

For Python Unittest framework you can use the unittest-xml-reporting module when configuring the tests, adding the XMLTestRunner in your test configuration.

1 2 3 4 5 6 7 8 9 10 11 12 test.py import unittest import xmlrunner class TestExample(unittest.TestCase): def testIsTrue(self): self.assertTrue(True) if __name__ == '__main__': unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))

Other test runners

For other test runners make sure that the XML xUnit-compatible test results are generated as a part of your build in one of the default supported locations.

Last modified on Dec 8, 2020
Cached at 8:54 PM on Mar 6, 2021 |

Additional Help

Ask the Community