Test reporting in Pipelines

We've made it easier to identify failed tests in your build. Test reporting will be automatically enabled in your pipeline when it detects JUnit or Maven Surefire XML 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 currently works with JUnit and Maven Surefire XML formats, 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
1 ./**/TestResults/**/*.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 plugins

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

PHPUnit

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

bitbucket-pipelines.yml

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

dotnet

For dotnet test reporting, there are 2 ways to generate compatible XML test results.

  • Using JUnitTestLogger to output JUnit format directly:

    bitbucket-pipelines.yml

    1 2 3 4 5 6 7 8 image: mcr.microsoft.com/dotnet/sdk pipelines: default: - step: script: - dotnet add package JUnitTestLogger --version 1.1.0 - dotnet test --logger "junit"

     

  • Using trx2unit to convert Visual Studio test result files (.trx) to JUnit test result files (.xml):

    bitbucket-pipelines.yml

    1 2 3 4 5 6 7 8 9 10 11 image: mcr.microsoft.com/dotnet/sdk pipelines: default: - step: script: - dotnet tool install -g trx2junit - dotnet test --logger 'trx;LogFileName=log.trx' after-script: - export PATH="$PATH:/root/.dotnet/tools" - trx2junit ./TestResults/*.trx

Other test runners

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

Additional Help