Giter Site home page Giter Site logo

covertool's Introduction

Build Status

covertool

covertool is a command line utility to manipulate go coverage reports. It can:

  • Merge reports together into one single report. This is useful to gather reports produced by different runs and consolidate the results.

Coverage beyond unit tests

Code coverage shouldn't be for unit tests only. There are many interesting things to say about getting coverage data for integration (end to end) tests. One may even want to gather coverage for a running service in production to get hot paths or detect unused part of an application.

I call this coverage-instrumented go binaries. The full story can be read in this blog post.

This repository contains support packages and tools to produce and use coverage-instrumented Go programs.

Package cover can be used to build instrumented programs.

Package exit is an atexit implementation.

The covertool utility can merge profiles produced by different runs of the same binary and display the resulting code coverage:

$ go install github.com/dlespiau/covertool
$ covertool merge -o all.go unit-tests.cov usecase1.cov usecase2.cov error1.cov error2.cov ...
$ covertool report all.go
coverage: 92.9% of statements

Finally, the example/calc directory contains a fully working example:

$ cd $GOPATH/src/github.com/dlespiau/covertool/examples/calc
$ ./run-tests.sh 
• Build the coverage-instrumented version of calc

• Run the unit tests
PASS
coverage: 7.1% of statements
ok  	github.com/dlespiau/covertool/examples/calc	0.003s

• Cover the sub() function
• Result: coverage: 57.1% of statements

• Cover the error path taken when not enough arguments are provided
expected 3 arguments, got 1
• Result: coverage: 21.4% of statements

• Cover the error path taken when providing an unknown operation
unknown operation: mul
• Result: coverage: 50.0% of statements

• Merge all coverage profiles and report the total coverage
coverage: 92.9% of statements

covertool's People

Contributors

dlespiau avatar jodh-intel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.