Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
engelmi committed Oct 25, 2022
1 parent 82eebca commit 7c1ef64
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@

A tool for defining and enforcing test coverage thresholds locally as well as in CI pipelines - similar to the coverage thresholds in JavaScripts popular Testing Framework [Jest](https://jestjs.io/docs/configuration#coveragethreshold-object).

`limgo` builds on top of the code coverage file generated by `go test` and extends it by a configuration file to define thresholds on directories and files using regular expressions. If those thresholds are not met, `limgo` will exit with code 1.

Currently, a coverage percentage as threshold can be defined for
- Statements
- Lines of Code
- Branches
`limgo` builds on top of the code coverage file generated by `go test` and extends it by a configuration file to define thresholds on directories and files using regular expressions. If those thresholds are not met, `limgo` will exit with code 1 and displays the coverage statistic for the module as well as a message which files do not meet any thresholds.
```
Files % Stmt % Line % Branch Uncovered Lines
github.com/GoTestTools/limgo 29.18 24.59 33.33
pkg/model/coverage 69.77 70.91 60.00
groupedCoverage.go 0.00 0.00 0.00 [10 11 12 13 15 16 17 18 19 20]
line.go 82.76 85.29 100.00 [55 63 71 79 87]
lineMatcher.go 85.71 90.91 50.00 [26]
...
Expected coverage thresholds not met:
'pkg/model/coverage/line.go': expected coverage threshold for statements of 100.00%, but only got 82.76%
```

## Installation

Expand Down Expand Up @@ -59,7 +66,7 @@ The following snippet shows a basic example usage of `limgo`:
go test ./... -coverprofile=cov.out

# verify that the coverage is not below the thresholds defined in .limgo.json
limgo -coverfile=cov.out -config=.limgo.json -v=1
limgo -coverfile=cov.out -config=.limgo.json -v=3
```

An overview as well as a short description of all supported flags can be displayed via
Expand All @@ -71,7 +78,7 @@ limgo -help

Coverage thresholds are defined in a configuration file. By default, `limgo` will search for a file named `.limgo.json`. This can be overridden by the `-config` flag.

Currently, coverage thresholds for `statements` and `functions` are supported. In the configuration file example below, thresholds are defined
Currently, coverage thresholds for `statements`, `lines` and `branches` are supported. In the configuration file example below, thresholds are defined
- on a global (project) level
- for all files in the "coverage" directory
- for all files in the "gosrc" directory starting with g
Expand All @@ -80,16 +87,19 @@ Currently, coverage thresholds for `statements` and `functions` are supported. I
"coverageThreshold": {
"global": {
"statements": 50,
"functions": 50
"lines": 55,
"branches": 33
},
"matcher": {
"pkg/coverage": {
"statements": 70,
"functions": 80
"lines": 70,
"branches": 33
},
"pkg/gosrc/g.*": {
"statements": 10,
"functions": 20
"lines": 15,
"branches": 50,
}
},
"excludes": [
Expand Down Expand Up @@ -132,7 +142,7 @@ jobs:
- name: Set up limgo - option 2
uses: GoTestTools/[email protected]
with:
version: "v0.0.0-beta"
version: "v0.0.1-beta"
install-only: true

# Run tests with coverprofile
Expand Down

0 comments on commit 7c1ef64

Please sign in to comment.