JUnit parser failing to find or parse test results

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Problem

JUnit parser failing to find or parse test results.

The following appear in Bamboo or agent's log:

1 2 3 4 5 6 7 8 9 10 11 12 13 2017-12-25 16:55:25,938 INFO [18-BAM::Local Agent 2::Agent:pool-33-thread-1] [TaskExecutorImpl] PLAN-KEY-JOB-2: Starting task 'Parse test results' of type 'com.atlassian.bamboo.plugins.testresultparser:task.testresultparser.junit' 2017-12-25 16:55:26,657 ERROR [pool-37-thread-1] [TestCollationServiceImpl] PLAN-KEY-JOB-2: Failed to parse test result file "C:\Atlassian\ApplicationData\Bamboo\xml-data\build-dir\PLAN-KEY-JOB\test_results.xml" org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at com.atlassian.bamboo.build.test.junit.JunitTestResultsParser.parse(JunitTestResultsParser.java:96) at com.atlassian.bamboo.build.test.junit.JunitTestResultsParser.parse(JunitTestResultsParser.java:85) at com.atlassian.bamboo.build.test.junit.JunitTestReportCollector.collect(JunitTestReportCollector.java:42) at com.atlassian.bamboo.build.test.TestCollationServiceImpl$1$1.run(TestCollationServiceImpl.java:129) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

Diagnosis

  • Make sure your test result was created in the build failing or you have the option Advanced options >> Pick up test results that were created outside of this build set in your JUnit parser task.

  • Your test result encoding is not configured to ASCII or UTF8 without BOM

  • One of the following messages are showing up in your build logs:

    1 2 simple 02-Aug-2017 13:59:36 Parsing test results under E:\bamboo_home\xml-data\build-dir\PLAN-KEY-JOB... error 02-Aug-2017 13:59:36 Failed to parse test result file "E:\bamboo_home\xml-data\build-dir\PLAN-KEY-JOB\test_results.xml"
    1 2 simple 02-Aug-2017 13:57:03 Parsing test results under E:\bamboo_home\xml-data\build-dir\PLAN-KEY-JOB... simple 02-Aug-2017 13:57:03 Failing task since test cases were expected but none were found.

Cause

The encoding is not correctly configured to ASCII or UTF8 without BOM

Solution

Resolution

Convert your file encoding to ASCII or UTF8 without BOM

  • In Unix like systems you should be change the encoding and remove the BOM using uconv:

    Find the original encoding using file

    1 file <YOUR_TEST_RESULT_FILE>

    Check that uconv can recognise this encoding.

    1 uconv --list

    Convert from the original encoding and remove the BOM using the --remove-signature option.

    1 2 mv results.junit.xml results.juxit.xml.orig uconv -f <GIVEN_ENCODING> -t UTF-8 results.junit.xml.orig --remove-signature -o results.junit.xml
  • In Windows you can use the following command to fix it:

    1 2 3 4 $MyPath = '${bamboo.build.working.directory}\path\to\filename' $MyFile = Get-Content $MyPath $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False) [System.IO.File]::WriteAllLines($MyPath, $MyFile, $Utf8NoBomEncoding)
Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.