gocov

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2022 License: BSD-3-Clause, MIT Imports: 1 Imported by: 42

README

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.

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.

Documentation

Overview

Package gocov is a code coverage analysis tool for Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Function

type Function struct {
	// Name is the name of the function. If the function has a receiver, the
	// name will be of the form T.N, where T is the type and N is the name.
	Name string

	// File is the full path to the file in which the function is defined.
	File string

	// Start is the start offset of the function's signature.
	Start int

	// End is the end offset of the function.
	End int

	// statements registered with this function.
	Statements []*Statement
}

func (*Function) Accumulate

func (f *Function) Accumulate(f2 *Function) error

Accumulate will accumulate the coverage information from the provided Function into this Function.

type Package

type Package struct {
	// Name is the canonical path of the package.
	Name string

	// Functions is a list of functions registered with this package.
	Functions []*Function
}

func (*Package) Accumulate

func (p *Package) Accumulate(p2 *Package) error

Accumulate will accumulate the coverage information from the provided Package into this Package.

type Statement

type Statement struct {
	// Start is the start offset of the statement.
	Start int

	// End is the end offset of the statement.
	End int

	// Reached is the number of times the statement was reached.
	Reached int64
}

func (*Statement) Accumulate

func (s *Statement) Accumulate(s2 *Statement) error

Accumulate will accumulate the coverage information from the provided Statement into this Statement.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL