Forked from Christopher Boumenot (boumenot)
At the time of this writing the repository appears to be on pause with several outstanding PRs, issues and forks with interesting contributions.
This repo aims to add improvements so that it can be used by our services.
This is a simple helper tool for generating XML output in Cobertura format for CIs like Jenkins and others from go tool cover output.
Just type the following to install the program and its dependencies:
$ go get github.com/bountylabs/gocover-cobertura
gocover-cobertura
reads from the standard input:
$ go test -coverprofile=coverage.out -covermode count ./
$ gocover-cobertura < coverage.out > coverage.xml
Note that you should run this from the directory which holds your go.mod
file.
Some flags can be passed (each flag should only be used once):
-
-by-files
Code coverage is organized by class by default. This flag organizes code coverage by the name of the file, which the same behavior as
go tool cover
. -
-ignore-dirs PATTERN
ignore directories matching
PATTERN
regular expression. Full directory names are matched, asgithub.com/bountylabs /gocover-cobertura
(and sogithub.com/bountylabs
andgithub.com
), examples of use:# A specific directory -ignore-dirs '^github\.com/bountylabs/gocover-cobertura/testdata$' # All directories autogen and any of their subdirs -ignore-dirs '/autogen$'
-
-ignore-files PATTERN
ignore files matching
PATTERN
regular expression. Full file names are matched, asgithub.com/bountylabs/gocover-cobertura/profile.go
, examples of use:# A specific file -ignore-files '^github\.com/bountylabs/gocover-cobertura/profile\.go$' # All files ending with _gen.go -ignore-files '_gen\.go$' # All files in a directory autogen (or any of its subdirs) -ignore-files '/autogen/'
-
-ignore-gen-files
ignore generated files. Typically files containing a comment indicating that the file has been automatically generated. See
genCodeRe
regexp in ignore.go.
- Yukinari Toyota (t-yuki)
- This tool is originated from gocov-xml by Alexey Palazhchenko (AlekSi)
- DarcySail's PR
- maxatome's PR
- elliotmr's branch