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:
Incorrect XML format
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.
Validate the generate XML file, to be sure it's in a correct XML format
Check if it's generated in a correct JUnit format
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
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
Was this helpful?