Skip to content

Latest commit

 

History

History
66 lines (49 loc) · 2.46 KB

README.md

File metadata and controls

66 lines (49 loc) · 2.46 KB

goverreport

Command line tool for coverage reporting and validation.

travis-c Coverage Status Maintainability

Installation

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.

Usage: goverreport [flags] -coverprofile=coverprofile.out

Flags:
  -coverprofile string
    	Coverage output file (default "coverage.out")
  -order string
    	Sort order: asc, desc (default "asc")
  -sort string
    	Column to sort by: filename, block, stmt, missing-blocks, missing-stmts (default "filename")
  -threshold float
    	Return an error code of 1 if the coverage is below a threshold
  -metric string
    	Use a specific metric for the threshold: block, stmt (default "block")

Example

$ goverreport -sort=block -order=desc -threshold=85

+------------------+--------+---------+-------+---------+---------------+--------------+
|       FILE       | BLOCKS | MISSING | STMTS | MISSING | BLOCK COVER % | STMT COVER % |
+------------------+--------+---------+-------+---------+---------------+--------------+
| report/view.go   |      4 |       0 |     7 |       0 |        100.00 |       100.00 |
| report/report.go |     47 |       5 |    60 |       5 |         89.36 |        91.67 |
| main.go          |     30 |      10 |    44 |      15 |         66.67 |        65.91 |
+------------------+--------+---------+-------+---------+---------------+--------------+
|      TOTAL       |   81   |   15    |  111  |   20    |     81 48     |    81 98     |
+------------------+--------+---------+-------+---------+---------------+--------------+
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:

threshold: 85
metric: stmt
root: "github.com/mcubik/goverreport"
exclusions: [test/it] # Exclude packages prefixed with "test/it"