Codecov combines Travis CI to test code coverage

Introduction to Codecov

Codecov is an open source test result display platform. Many open source projects on Github use Codecov to display single test results. Codecov supports Github account login and will also synchronize projects in Github.

The role of Codecov

  • Visualized results, connected to github, providing small badges
  • Automatically merge test results and run them in parallel

Introduction to Travis CI

Travis CI is a managed, distributed continuous integration tool mainly used to build and automatically test projects. When you push a piece of code to github, Travis will automatically test it according to your pre-configured test file and put back the pass or fail results. It only supports Github and does not support other code hosting services.

Travis simple steps to use

  • github authorization and panel
  • Get the github token
  • Configuration project.travis.yml
  • other

Steps for usage

  1. Install dependencies
yarn add nyc codecov -D
  1. Adding package.jsonscript
  "scripts": {
    
    
    "test:unit": "nyc vue-cli-service test:unit",
    "coverage": "nyc report --report=text-lcov > coverage.lcov && codecov"
  },
  1. Script .travis.yml_
langeuage: node_js
node_js: 
  - '14'

cache:
  directories:
    - node_modules

install:
  - npm install

script:
  - npm run test:unit

after_success:
  - npm run coverage
  1. Log in to codecov with your Github account
    Insert image description here
    and click on the warehouse to get the corresponding token for use in the next step.
    Insert image description here

  2. Log in to Travis with your Github account, synchronize the warehouse on Github, find the corresponding warehouse and click in to
    Insert image description here
    set the token, as follows
    Insert image description here

  3. Click Trigger build to build the project
    Insert image description here

  4. View Results

Badge
Insert image description here
more github small icons

testing report
Insert image description here

project

Guess you like

Origin blog.csdn.net/kiscon/article/details/118275722