Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to enable code coverage in bitbucket piplines for my Laravel project.

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.2

options:
max-time: 30
pipelines:
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

 

2 answers

@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

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?

Thanks,

Phil

Like rastogi_nitin likes this
0 votes

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.

Like Barbara Ondrisek likes this

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? 

Thanks,

Phil

@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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,741 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you