How to enable code coverage in bitbucket piplines for my Laravel project.Here my bitbucket-pipelines.yml
# This is a sample build configuration for PHP.# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.# Only use spaces to indent your .yml configuration.# -----# You can specify a custom docker image from Docker Hub as your build environment.image: laratools/ci:7.2options: max-time: 30pipelines: branches: master, dev: - step: caches: - composer script: - composer install --no-progress --no-suggest - export APP_ENV=testing - cp .env.example .env - php artisan key:generate - vendor/bin/phpunit --log-junit ./test-reports/junit.xml
Hello,
Do you mean failed tests reporting, or test code coverage (which checks how many LoC are reached by all tests). From your phpunit command, it looks like the first.
If you mean failing test reporting. Have a look at the documentation here: https://confluence.atlassian.com/bitbucket/test-reporting-in-pipelines-939708543.html You should see some information in the 'Build teardown' that will include if the junit.xml file is found, and if it's parsed any failed tests. The UI will only show failed tests.
If you mean test code coverage, we currently don't support that. You'll need to output that to the logs or to an artifact to download: https://confluence.atlassian.com/bitbucket/using-artifacts-in-steps-935389074.html
Thanks,
Phil
Hi Phil. Any chance code coverage could be integrated into bitbucket pipelines? It would be really helpful to review that as part of a pull request.
@Philip Hodder I'm sorry to this late response, yes I mean how much of my code testing in the build I need to add some rules depending that step in my pipeline
eg: code only move to production if coverage is 100%
something like that
Hi Ken,
I agree it would be a useful feature to have. However, we currently have other features prioritised and haven't got Code Coverage on our immediate roadmap.
We have an open feature request for it here, which you can follow for updates: https://bitbucket.org/site/master/issues/15935/show-code-coverage-reports-for-jacoco Matt has posted a possible work around using the Build Status API (which some of our teams at Atlassian currently do).
Out of curiosity, which code coverage tools are you currently using?
No worries for the delay.
We haven't scheduled any time to start looking into integrating Code Coverage directly into Pipelines. However, it sounds like you want to prevent a deployment from running based on the test coverage. In that case you could enforce that as part of your deploy step (or an earlier one).
For example:
pipelines: branches: master: - step: script: - ./run-the-build - ./run-the-tests - ./verify-code-coverage # This would check for code coverage requirements, and fail the build if not met. - ./deploy-to-production
Or if you wanted to enforce this on a PR:
pipelines: branches: feature/*: - step: name: Build and test script: - ./run-the-build - ./run-the-tests - ./verify-code-coverage # This would check for code coverage requirements, and fail the build if not met. master: - step: name: Build and test artifacts: - binary-to-deploy script: - ./run-the-build - ./run-the-tests - step: name: Deploy to production deployment: production script: - ./deploy-to-production
If you're interested in built in support for code coverage tools, can you follow this feature request and provide more details of your use-case?
@Philip Hodder In our case we are using node.js and using tools like nyc or c8
They both support this reporters : https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-reports/lib
It looks like you're new here. Sign in or register to get started.