Troubleshooting "invalid testcase element" error when uploading test results


When uploading your test results to CircleCI in a job, you may see the following error:

invalid testcase element

This can happen when CircleCI is unable to parse the test results generated by your test runner.


Please verify the content of the test resultsby uploading the file as an artifact. This is helpful to verify what is being parsed by CircleCI. Here is an example of how to upload an artifact:

- store_artifacts:
    path: test-results.xml


  • Solution - Use xmlstarlet to manipulate xml element names
    • It will be necessary to modify the element names so that they are accepted by CircleCI's test result parser. One tool that can be used is xmlstarlet.

      Here is an example of a job step that renames the invalid elements flakyFailture, rerunFailure, and flakyError to failure in a file named test.xml:

      - run:
          name: Correct formatting of test results
          command: |
            xmlstarlet ed --inplace --rename '//testsuite/testcase/flakyFailure' -v 'failure' test.xml
            xmlstarlet ed --inplace --rename '//testsuite/testcase/rerunFailure' -v 'failure' test.xml
            xmlstarlet ed --inplace --rename '//testsuite/testcase/flakyError' -v 'failure' test.xml


After adjusting the element names, your test results will be corrected parsed by CircleCI, and the invalid element error will no longer show.

Additional Notes:

The above example shows how to rename specific elements, but there are cases when the nesting of elements is invalid as well. Please refer to the documentation below for more information:

XmlStarlet Reference

Additional Resources: 

Was this article helpful?
0 out of 0 found this helpful



Article is closed for comments.