项目作者: mcubik

项目描述 :
Command line tool for coverage reporting and validation
高级语言: Go
项目地址: git://github.com/mcubik/goverreport.git
创建时间: 2018-01-28T17:44:09Z
项目社区:https://github.com/mcubik/goverreport

开源协议:MIT License

下载


goverreport

Command line tool for coverage reporting and validation.

travis-c
Coverage Status
Maintainability

Installation

  1. go get -u github.com/mcubik/goverreport

Usage

goverreport reads a coverage profile and prints a report on the terminal. Optionally, it can also validate a coverage threshold.

  1. Usage: goverreport [flags] -coverprofile=coverprofile.out
  2. Flags:
  3. -coverprofile string
  4. Coverage output file (default "coverage.out")
  5. -metric string
  6. Use a specific metric for the threshold: block, stmt (default "block")
  7. -order string
  8. Sort order: asc, desc (default "asc")
  9. -packages
  10. Report coverage per package instead of per file
  11. -sort string
  12. Column to sort by: filename, package, block, stmt, missing-blocks, missing-stmts (default "filename")
  13. -threshold float
  14. Return an error code of 1 if the coverage is below a threshold

Example

  1. $ goverreport -sort=block -order=desc -threshold=85
  2. +------------------+--------+---------+-------+---------+---------------+--------------+
  3. | FILE | BLOCKS | MISSING | STMTS | MISSING | BLOCK COVER % | STMT COVER % |
  4. +------------------+--------+---------+-------+---------+---------------+--------------+
  5. | report/view.go | 4 | 0 | 7 | 0 | 100.00 | 100.00 |
  6. | report/report.go | 47 | 5 | 60 | 5 | 89.36 | 91.67 |
  7. | main.go | 30 | 10 | 44 | 15 | 66.67 | 65.91 |
  8. +------------------+--------+---------+-------+---------+---------------+--------------+
  9. | TOTAL | 81 | 15 | 111 | 20 | 81 48 | 81 98 |
  10. +------------------+--------+---------+-------+---------+---------------+--------------+
  11. exit status 1

Configuration

You can use a fixed threshold by configuring it in the .goverreport.yml configuration file. This file also
lets you configure the root path of the project, so that it gets stripped from the names of the files, and a set of path prefixes to be excluded from the report.

Here’s an example:

  1. threshold: 85
  2. thresholdType: stmt
  3. root: "github.com/mcubik/goverreport"
  4. exclusions: [test/it] # Exclude packages prefixed with "test/it"