Giter Club home page Giter Club logo

gocov's Introduction

gocov

Coverage testing tool for The Go Programming Language

Build Status

Installation

go get github.com/axw/gocov/gocov

Usage

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

gocov test

Running gocov test <package> will, for the specified package, instrument all imported packages not part of the standard library, and run "go test". Upon completion, coverage data will be emitted in the form of a JSON document.

Controlling instrumentation

By default only the specified package will be instrumented and consequently have coverage information provided for. There are several flags that can change this behaviour.

By running gocov test -deps <package> you direct gocov to recursively instrument package dependencies, in which case coverage information will be provided for all dependencies as well. The coverage information provided is relative only to the tests run in the originally specified package.

e.g. If you run gocov test -deps net/http, then you will see coverage information not just for net/http, but also its dependencies; the output tells you what code in the dependencies is exercised when the net/http tests are run.

If you specify -deps but wish to exclude a specific package from instrumentation, you can pass an additional -exclude flag, e.g. gocov test -deps -exclude comma,separated,packages. If you wish to exclude all packages in GOROOT, then you can use the shortcut -exclude-goroot flag instead.

gocov report

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

Output from gocov test is logged to stdout so users with POSIX compatible terminals can direct the output to gocov report to view a summary of the test coverage, for example: -

gocov test mypackage | 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

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

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

goveralls: Go integration for Coveralls.io continuous code coverage tracking system.

gocov's People

Contributors

axw avatar davecheney avatar aleksi avatar gward avatar djhworld avatar pjvds avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.