[PYTHON] View pytest coverage results from CircleCI

Overview

I published the test coverage report as HTML, but I don't know how to view it from CircleCI!

For those who like, I will write how to view the coverage report from CircleCI

Caution

It's pretty aggressive, so I think there's a better way. If you know any good way, please leave a comment

procedure

  1. Issue a coverage report
  2. Modify config.yml to make it accessible as Artifacts

Issue a coverage report

It doesn't matter how you put it out, but I'm going to do it with pytest (because it's easy)

For code in the src directory, issue an HTML coverage report in the test-reports directory

pytest --cov=src --cov-report=html:test-reports

Tweak config.yml

version: 2
jobs:
  build:
    docker:
      - image: circleci/python:3.7.2
    steps:
      (abridgement)
      - run:
          name: run test
          command: |
            . venv/bin/activate
            pip install pytest
            pip install pytest-cov
            pytest --cov=src --cov-report=html:test-reports
      - store_artifacts:
          path: test-reports/
          destination: circleci-docs

If you do, the coverage report files will be displayed in the ʻArtifacts` part as shown in the image below.

image.png

If you step on this ʻindex.html`, you can see the coverage report! Hooray

Click the file name to see the results for each file properly

It's the end

Recommended Posts

View pytest coverage results from CircleCI
View flask coverage with pytest-cov