Coverage testing tool for The Go Programming Language

gocov

Coverage reporting tool for The Go Programming Language

Build Status

Installation

go get github.com/axw/gocov/gocov

Usage

There are currently four gocov commands: test, convert, report and annotate.

gocov test

Running gocov test [args...] will run go test [args...] with an implicit -coverprofile added, and then output the result of gocov convert with the profile.

gocov convert

Running gocov convert <coverprofile> will convert a coverage profile generated by go tool cover to gocov's JSON interchange format. For example:

go test -coverprofile=c.out
gocov convert c.out | gocov annotate -

gocov report

Running gocov report <coverage.json> will generate a textual report from the coverage data output by gocov convert. It is assumed that the source code has not changed in between.

Output from gocov test is printed to stdout so users can pipe the output to gocov report to view a summary of the test coverage, for example: -

gocov test | gocov report

gocov annotate

Running gocov annotate <coverage.json> <package[.receiver].function> will generate a source listing of the specified function, annotating it with coverage information, such as which lines have been missed.

Related tools and services

GoCovGUI: A simple GUI wrapper for the gocov coverage analysis tool.

gocov-html: A simple helper tool for generating HTML output from gocov.

gocov-xml: A simple helper tool for generating XML output in Cobertura format for CIs like Jenkins and others from gocov.

Owner
Comments
  • feature request: gocov test should accept multiple packages to test

    feature request: gocov test should accept multiple packages to test

    gocov should accept the path globs that go test does. ie

    gocov test ./... gocov test std

    The goal is to be able to produce test coverage for an entire project, ie

    gocov test launchpad.net/juju-core/... | gocov report

    Internally gocov will execute an independent instrumentAndTest() for each package.

  • annotate: option to only produce results for <100% coverage

    annotate: option to only produce results for <100% coverage

    Discovered this nice tool a few days ago. Thank you for making it available. What I would like is an option to annotate to only show routines that have less than 100% coverage (= have at least one 'miss' mark). That could be of help to quickly find out where exactly testing could be improved. Johan

  • no Go source files

    no Go source files

    I'm not quite sure what's happening here, but I'm trying to run tests in github.com/couchbaselabs/cbgb/cbgb and I get the following:

    /var/folders/nt/_3y11_t12szbmgshvz6zgbhh0000gn/T/gocov343768907/src/pkg/github.com/couchbaselabs/cbgb/cbgb/main.go:11:2: no Go source files in /var/folders/nt/_3y11_t12szbmgshvz6zgbhh0000gn/T/gocov343768907/src/pkg/github.com/couchbaselabs/cbgb
    go test failed: exit status 1
    failed to parse gocov output: stat /var/folders/nt/_3y11_t12szbmgshvz6zgbhh0000gn/T/gocov343768907/gocov.out: no such file or directory
    
  • If a package has no test files, the lines in that package are not added to the total line count.

    If a package has no test files, the lines in that package are not added to the total line count.

    As described in the issue title.

    Ideally, when I run gocov test ./... under a certain project folder, I want to see the reported total line numbers be the total lines to be covered in the project, no matter whether there is test file existing for a certain package or not.

    However, this is not what gocov does for now, in my experiments. It seems that if there is no test file existing for a certain package, the line numbers in that package are not added to the total line number count. (please let me know if you are not able to replicate this result. :)

    Also, in some circumstances, we don't want to add tests for some packages, for example, some packages are solely for testing purposes like mocks, testdata etc. If we do want to count lines no matter whether there is test file existing, we should also add an option to ignore packages. That would make the tool report the total line numbers correctly as I expect.

    Thanks!

    P.S. gocov is really an awesome and handy tool! It enables and empowers me to do my testing job! :)

  • gocov reports test coverage on transitive dependencies

    gocov reports test coverage on transitive dependencies

    Hello,

    I may be mistaking something, but for some reason gocov will annotate and report coverage on transitive dependencies. Am I missing something, or is this a bug ?

    % go get github.com/davecheney/a/... % gocov test github.com/davecheney/a/b | gocov report warning: building out-of-date packages: github.com/axw/gocov github.com/davecheney/a time os fmt flag runtime/pprof testing installing these packages with 'go test -i github.com/davecheney/a/b' will speed future tests.

    ok github.com/davecheney/a/b 0.008s

    github.com/davecheney/a/a.go A 100.00% (1/1) github.com/davecheney/a - 100.00% (1/1)

    github.com/davecheney/a/b/b.go B 66.67% (2/3) github.com/davecheney/a/b - 66.67% (2/3)

    Why is the coverage of package a being reported ?

  • False Duplicate Package Name panic

    False Duplicate Package Name panic

    In some cases, the 'gocov test' is generating a json file which contains duplicate package name records. This is happening despite the fact that there is not a duplicate package name. Due to this incorrect behavior the generated json is unusable by the 'gocov report' as the condition on line 88 in report.go is met and panic("package already exists: result merging not implemented yet") is executed.

  • Add support for test coverage merging; e.g. gocov test ./...

    Add support for test coverage merging; e.g. gocov test ./...

    go test -cover refuses to run tests from multiple package at once. I wrote a function to work around this in TestCoverage.run(), see https://github.com/maruel/pre-commit-go/blob/master/checks/checks.go#L532.

    It runs each package test independently and concurrently, each with their own coverage file, then merges all the coverage files into one. It's ~130 lines of code in practice.

    This feature request is to handle this automatically and transparently inside gocov so that the following command would work:

    gocov test ./... | gocov report
    
  • XML-output in Cobertura format

    XML-output in Cobertura format

    It would be nice to have an output in Cobertura format for integration with Jenkins/Hudson and other CIs. Example is there: https://raw.github.com/jenkinsci/cobertura-plugin/master/src/test/resources/hudson/plugins/cobertura/coverage-with-data.xml

  • Compile error with Go 1.0.3 on Windows

    Compile error with Go 1.0.3 on Windows

    As the title indicates, this will not compile with Go 1.0.3 on Windows as of commit cacb452347903453c8483c92e2ce1842c1ceef8a.

    The error message is: $GOPATH\src\github.com\axw\gocov\io.go:35: cannot use int(w) (type int) as type syscall.Handle in function argument.

  • Getting the expected pwd instead of the generated pwd

    Getting the expected pwd instead of the generated pwd

    In my testing code, I use relative paths to pull in fixtures (non-go files). This however doesn't work because there is a new, temporary path being generated such as:

    /var/folders/qy/zmrxj1t14mnbxsxrz9gtknxc0000gn/T/gocov672324733/src/pkg/github.com/imosquera/uploadthis/conf

    for gocov to work. Whats the best way to get the original file path?

  • Cannot pass parameters to `go test`

    Cannot pass parameters to `go test`

    Sorry if I'm just blind to see it(1), but it seems to me that there's no way to pass-through parameters to the "underlying" 'go test'.

    Specifically, my problem is that I need to add -timeout (or -test.timeout) as the package I want to run gocov against is taking about 4 minutes to test w/o the coverage tooling and it timeouts after 600 secs with it.

    However, the need to pass any other parameters is a general problem, which should be addressed (if not solved already[1]).

  • gocov with coverprofile raise error, the file path contains duplicate parts

    gocov with coverprofile raise error, the file path contains duplicate parts

    I have got the kubernetes coverprofile with make test, I want to convert the profile to html with gocov-html, but when I run gocov to convert the combined-coverage.out to json format under the dir of /opt/zz/kubernetes which is the source root of my code, it raise the following error messages: error: open /opt/zz/kubernetes/vendor/k8s.io/kubernetes/vendor/k8s.io/api/core/v1/generated.pb.go: no such file or directory unmarshal coverage data: unexpected end of JSON input

    I found that the file exist, but the path with duplicate parts, the exist file path is /opt/zz/kubernetes/vendor/k8s.io/api/core/v1/generated.pb.go, I guess that there must be some misconfiguration, can anyone help me? image

  • [question] Is it possible to exclude a method from code coverage?

    [question] Is it possible to exclude a method from code coverage?

    I would like to exclude some deprecated methods from the code coverage calculation. Is it currently possible to add a comment above the method which tells gocov to not count this method against the final result?

  • gocov failed when trying on file that has a formatting directive

    gocov failed when trying on file that has a formatting directive

    Running the command: gocov test /go/src/github.com/xxx/fff/xx-controller/... | gocov-xml > /reports/coverage.xml it fails with: # github.com/xxx/fff/xx-controller/router #11 12.45 xx-controller/router/router.go:168: Info call has possible formatting directive %#v #11 12.48 error: exit status 2 #11 12.48 panic: EOF

    The code is log.Info("NoRoute claims: %#v\n", claims)

  • gocov output data format as standard go test does?

    gocov output data format as standard go test does?

    Is it possible to generate output in the same format as standard go test does? Some tools require output to be in standard go test format, not json. I wonder if there is any limitation to do this. In theory it could be directly generated from json... however I'm not sure if there are any known limitations?

  • Automated tests for

    Automated tests for "gocov test"

    The instrumentation code has become increasingly complex. As bugs are fixed, new ones are getting introduced; automated tests would be useful to mitigate this.

Hsuan-Fuzz: REST API Fuzzing by Coverage Level Guided Blackbox Testing
Hsuan-Fuzz: REST API Fuzzing by Coverage Level Guided Blackbox Testing

Hsuan-Fuzz: REST API Fuzzing by Coverage Level Guided Blackbox Testing Architecture Usage package main import ( restAPI "github.com/iasthc/hsuan-

Nov 30, 2022
The portal gates to coverage reports
The portal gates to coverage reports

Covergates - Portal Gates to Coverage Reports Purpose Covergates is to make the easiest way to setup a self-hosted coverage report service. It's an al

Dec 18, 2022
go-carpet - show test coverage in terminal for Go source files
go-carpet - show test coverage in terminal for Go source files

go-carpet - show test coverage for Go source files To view the test coverage in the terminal, just run go-carpet. It works outside of the GOPATH direc

Jan 8, 2023
Generate a test coverage badge like this one for your go projects.

coverage-badge-go ?? Generate a test coverage badge like this one for your go projects. Usage on: pull_request: branches: -

Dec 11, 2022
Test coverage in Go, the whole package

Test coverage in Go, the whole package

Jan 20, 2022
Powerful mock generation tool for Go programming language

Summary Minimock generates mocks out of Go interface declarations. The main features of minimock are: It generates statically typed mocks and helpers.

Dec 17, 2022
siusiu (suite-suite harmonics) a suite used to manage the suite, designed to free penetration testing engineers from learning and using various security tools, reducing the time and effort spent by penetration testing engineers on installing tools, remembering how to use tools.
siusiu (suite-suite harmonics) a suite used to manage the suite, designed to free penetration testing engineers from learning and using various security tools, reducing the time and effort spent by penetration testing engineers on installing tools, remembering how to use tools.

siusiu (suite-suite harmonics) a suite used to manage the suite, designed to free penetration testing engineers from learning and using various security tools, reducing the time and effort spent by penetration testing engineers on installing tools, remembering how to use tools.

Dec 12, 2022
A yaml data-driven testing format together with golang testing library

Specimen Yaml-based data-driven testing Specimen is a yaml data format for data-driven testing. This enforces separation between feature being tested

Nov 24, 2022
Rich testing for the Go language

Instructions Install the package with: go get gopkg.in/check.v1 Import it with: import "gopkg.in/check.v1" and use check as the package name inside

Dec 9, 2022
Hamcrest matchers for the Go programming language

Note: This has not been maintained and/or updated since 2011. Perhaps consider corbym/gocrest, instead. Introduction Hamcrest is a fluent framework fo

Sep 27, 2022
GoMock is a mocking framework for the Go programming language.

gomock GoMock is a mocking framework for the Go programming language. It integrates well with Go's built-in testing package, but can be used in other

Dec 28, 2022
Package cdp provides type-safe bindings for the Chrome DevTools Protocol (CDP), written in the Go programming language.

cdp Package cdp provides type-safe bindings for the Chrome DevTools Protocol (CDP), written in the Go programming language. The bindings are generated

Jan 7, 2023
Fortio load testing library, command line tool, advanced echo server and web UI in go (golang). Allows to specify a set query-per-second load and record latency histograms and other useful stats.
Fortio load testing library, command line tool, advanced echo server and web UI in go (golang). Allows to specify a set query-per-second load and record latency histograms and other useful stats.

Fortio Fortio (Φορτίο) started as, and is, Istio's load testing tool and now graduated to be its own project. Fortio is also used by, among others, Me

Jan 2, 2023
A next-generation testing tool. Orion provides a powerful DSL to write and automate your acceptance tests

Orion is born to change the way we implement our acceptance tests. It takes advantage of HCL from Hashicorp t o provide a simple DSL to write the acceptance tests.

Aug 31, 2022
Stress testing and benchmarking tool for the NEAR EVM

evm-bully --- stress testing and benchmarking tool for the NEAR EVM

May 30, 2022
HTTP load testing tool and library. It's over 9000!
HTTP load testing tool and library. It's over 9000!

Vegeta Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a

Jan 7, 2023
Ddosify - High-performance load testing tool
 Ddosify - High-performance load testing tool

Ddosify - High-performance load testing tool Features ✔️ Protocol Agnostic - Currently supporting HTTP, HTTPS, HTTP/2. Other protocols are on the way.

Jan 5, 2023
Merge Mock - testing tool for the Ethereum Merge

MergeMock Experimental debug tooling, mocking the execution engine and consensus node for testing. work in progress Quick Start To get started, build

Oct 21, 2022
Ditto is a CLI testing tool that helps you verify if multiple HTTP endpoints have the same outputs.

Ditto is a CLI testing tool that helps you verify if multiple HTTP endpoints have the same outputs.

Nov 24, 2021