How do you know your tests actually exercise your code? Perhaps you’re using a code coverage tool like . .
Using Codecov
It’s really easy to get started. Codecov offers a is one of them. (If you have private pipelines on Azure Pipelines or anyplace else, you can still use Codecov and will need to manage a token.)
Connecting with Azure Pipelines
To give it a try for yourself, clone one of Codecov’s , so that’s where I started. It’s a toy Python project with two methods and one test. You’ll have to change two things about that example repo:
- Replace .travis.yml with an Azure Pipelines YAML definition.
- Instead of using the Python
codecovuploader, rely on the Bash uploader.
Here’s my example Azure Pipelines file:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
Python35:
python.version: '3.5'
Python36:
python.version: '3.6'
Python37:
python.version: '3.7'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
- script: |
python -m pip install --upgrade pip
pip install coverage
displayName: 'Install coverage'
- script: |
coverage run tests.py
displayName: 'Run tests'
- script: |
bash <(curl -s https://codecov.io/bash)
displayName: 'Upload to codecov.io'
Showing it off
After I install the Codecov GitHub app and run this pipeline, Codecov handles the rest for me. Here’s an example of the graphs it generates:
appeared first on Azure DevOps Blog.
SOCIAL SHARE CARD GENERATOR