Overview
When uploading JUnit XML results via store_test_results, the "Tests" tab displays an incorrect test count.
Root Cause
When the test results parser encounters a <system-out> element nested inside a <testcase> element, it overwrites the result field with the stdout content, causing the test count in the "Tests" tab to be displayed incorrectly.
Solution
Remove the <system-out> tags and their content from your JUnit XML file before passing it to store_test_results.
Add the following step to your CircleCI config after your test run and before store_test_results:
- run:
name: Remove system-out tags from JUnit XML
command: |
awk '/<system-out>/{skip=1} !skip{print} /<\/system-out>/{skip=0}' <path_to_tests_file_dir>/tests.xml > <path_to_tests_file_dir>/results.xmlNote: The awk command removes all <system-out> tags in the file, regardless of where they appear. If your JUnit XML contains <system-out> elements outside of <testcase> elements that you wish to keep, you will need to modify the command accordingly.
If you would like to keep the original file for debugging, you may store the original file as an artifact:
- store_artifacts:
path: <path_to_tests_file_dir>/tests.xmlThen your store_test_results step should follow immediately after:
- store_test_results:
path: <path_to_tests_file_dir>/results.xml