Failed uploading test results for "PHPUnit coverage"

Hello.
I’m not sure if this is a bug, but I don’t think it should be. Below are the details of the situation I faced.

We have an ORB (helium10/h10-phpcs-review) which has this code:

 - when:
      condition: << parameters.phpunit-parallelism >>
      steps:
        - run:
            name: Run PhpUnit tests in parallel mode
            command: |
              if [ $(docker exec --workdir=/app << parameters.container-name >> composer show -N 2>/dev/null | grep -c paratest) != "0" ];
                then
                docker exec --workdir=/app << parameters.container-name >> ./artisan test --parallel \
                  <<# parameters.code-coverage >> --coverage-clover tests/reports/phpunit.coverage.xml <</ parameters.code-coverage >>;
                else
                docker exec --workdir=/app << parameters.container-name >> /app/vendor/bin/phpunit \
                  <<# parameters.code-coverage >> --coverage-clover tests/reports/phpunit.coverage.xml <</ parameters.code-coverage >>;
              fi
  - when:
      condition: << parameters.code-coverage >>
      steps:
        - run:
            name: Extract test report from a docker container
            command: |
              mkdir -p tests/reports
              docker cp << parameters.container-name >>:/app/tests/reports tests
              sed -i 's@/app/tests/@tests/@g' tests/reports/phpunit.junit.xml
              sed -i 's@/app/app/@app/@g' tests/reports/phpunit.coverage.xml
        - store_test_results:
            path: tests/reports
        - store_artifacts:
            path: tests/reports

When we use this orb in the project, the task works correctly, testing is performed, but at the step “- store_test_results:” I get the following error:

Archiving the following test results

  • /home/circleci/project/tests/reports/phpunit.coverage.xml
  • /home/circleci/project/tests/reports/phpunit.junit.xml

failed uploading test results: File: home/circleci/project/tests/reports/phpunit.coverage.xml had the following problems:

  • invalid top level element: coverage

At the same time, the task does not fall and the workflow continues to work.

I tried changing the coverage report formats using the PHPUnit settings, but the error does not go away, only the message about the wrong top-level element changes.

And here is my questions:

  1. Why does the “store_test_results” command give an error for the standard xml report generated by phpunit in “Clover XML” format?
  2. How to get rid of this error?

I would appreciate any ideas and answers on this topic. =)

Do you have a way to share the XML that is getting generated by any chance? I think what might be happening is that the test results XML is including an attribute that is seen as “invalid” by our logic that checks to make sure before we upload the test results if the XML schema is valid.

Yes, of course, I will be happy to share the file, if you tell me how it can be attached to the message here or what e-mail to send it for analysis?
Placing +10 thousand lines of the source file of the report in this message would be a very stupid step, I suppose.

you can send it to

sebastian @ circleci.com

Sent the file to the email you provided. Please check the received file.

After inspecting the XML file provided by @karageorg, we’ve come to the conclusion that this is not necessarily a bug, just a possibly confusing user experience.

For clarity, store_test_results only supports JUnit XML files as described in this docs page and will show test results in the “Tests” tab if they are in the correct XML schema. Code coverage reports will not show its results in the “Tests” tab because these reports typically do not have the JUnit XML schema that is expected to show output in the “Tests” tab.

There is currently no plan to have a tab for Code Coverage results similar to the “Tests” tab, but this is something that we are considering for the future. No timeline to share at this time. Please make sure to upvote this Canny request if you think that this is something you’d find valuable as Canny is our tool for tracking feature requests. You can also follow updates for new functionality on our public roadmap.

1 Like

Thanks a lot for your time and explanation. =)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.