JUnit Parser task in Bamboo shows 'Failed to parse test result file' error when parsing test results file

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

Problem

When running the JUnit Response Parser task in Bamboo in a previously generated XML test results file, you may get the following error:

1 Failed to parse test result file /working_dir/tests_results.xml

Cause

As the error states, Bamboo is unable to parse the test file. This may be caused by:

  1. Incorrect XML format

  2. Invalid characters in the file

Diagnosis and Fix

To fix this problem, it's necessary to identify what in the file is not correct and either make sure it's correctly generated so Bamboo can identify it correctly or add a previous task to fix it (you can use a script task for it). This may include some trial and error.

  1. Validate the generate XML file, to be sure it's in a correct XML format

  2. Check if it's generated in a correct JUnit format

  3. Run the following command to check the file (this may show invalid characters in the file):

    1 xmllint --noout (--schema schema.xsd) test_results.xml
  4. Run the following command to remove any unprintable characters:

    1 strings test_results.xml > fixed_test_results.xml

    This command may remove characters you didn't expect to be removed or add new lines characters. This is better used as a diagnosis tool (apply and see if fixed) then a definitive fix. You can compare the two files using this command:

    1 diff test_results.xml fixed_test_results.xml
Updated on April 15, 2025

Still need help?

The Atlassian Community is here for you.