Can't read phpunit report file

Laravel application using Bitbucket Cloud.

I’m trying to get the coverage for Sonarcloud to work.

I am using phpunit to generate the coverage and junit files.

It looks like its pointing to /opt/atlassian/pipelines/agent/build for some reason.

However the sonarcloud scan cannot pick them up.

Do I need to move the report files?

INFO: Importing /opt/atlassian/pipelines/agent/build/test-reports/junit.xml
ERROR: An error occurred when reading report file '/opt/atlassian/pipelines/agent/build/test-reports/junit.xml', nothing will be imported from this report. IOException: /opt/atlassian/pipelines/agent/build/test-reports/junit.xml (No such file or directory)
INFO: Importing /opt/atlassian/pipelines/agent/build/test-reports/coverage.xml
ERROR: An error occurred when reading report file '/opt/atlassian/pipelines/agent/build/test-reports/coverage.xml', nothing will be imported from this report. IOException: /opt/atlassian/pipelines/agent/build/test-reports/coverage.xml (No such file or directory)
php -d pcov.enabled=1 -d pcov.directory=. ./vendor/phpunit/phpunit/phpunit --stop-on-error --stop-on-failure --fail-on-risky --coverage-clover=./test-reports/coverage.xml --log-junit=./test-reports/junit.xml

Hey there.

How is your Bitbucket Pipelines YML configured? Please feel free to share it here.

Here are the steps in the pull request bitbucket-pipelines.yml file.

          - step:
              name: Phpunit - Testing
              clone:
                enabled: false
              script:
                - apt-get update && apt-get install -y php-pcov
                - ./scripts/phpunit.sh
          - step:
              name: Security Checks
              clone:
                enabled: false
              script:
                - pipe: sonarsource/sonarcloud-scan:1.4.0
                - pipe: sonarsource/sonarcloud-quality-gate:0.1.6

I have fixed it now by adding the artifacts to the phpunit step:

          - step:
              name: Phpunit - Testing
              clone:
                enabled: false
              script:
                - apt-get update && apt-get install -y php-pcov
                - ./scripts/phpunit.sh
              artifacts:
                - test-reports/coverage.xml
                - test-reports/junit.xml
2 Likes

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