gocov

command module
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 13 Imported by: 0

README

gocov

Exclude some code from test coverage reports

  • Originally github.com/dave/courtney
  • Main differences
    • gocov does NOT implicitly exclude any code
    • gocov prints not-covered lines in a format which is understandable by VS Code:
The following lines are not tested:
./context.go:47:2
./context.go:102:101
./ebnf.go:105:18
./ebnf.go:114:17
./ebnf.go:118:19
./ebnf/ebnf.go:41:26

Quick start:

  • Install: go install github.com/heeus/gocov@latest
  • Exclude code from test coverage:
    • Exclude the rest of the code block forever: // notest
    • Exclude the rest of the code block due to lack of time: // notestdept
  • Show coverage-excluded code:
    • Excluded by // notest: gocov notest
    • Excluded by // notestdept : gocov notestdept
  • Run tests and show uncovered lines:
    • Current package: gocov .
    • Current package + sub-packages: gocov ./...
    • Default (if nothing specified): ./...
  • Verbose mode
    • Show output from the go test -v: gocov -v

Exclusion nuances

func foo() {
  fmt.Println("foo 1")
  fmt.Println("foo 2")
  // notest
  fmt.Println("foo 3") // excluded
  fmt.Println("foo 4") // excluded
}
func foo() {  
  fmt.Println("foo 1")
  fmt.Println("foo 2")
  {
    // notest
    fmt.Println("foo 3") // excluded
  }
  fmt.Println("foo 4")
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
package paths to filesystem directories and vice versa.
package paths to filesystem directories and vice versa.
builder
package builder can be used in testing to create a temporary go module or gopath, src, namespace and package directory, and populate it with source files.
package builder can be used in testing to create a temporary go module or gopath, src, namespace and package directory, and populate it with source files.
vos
Package vos is a virtual os tool.
Package vos is a virtual os tool.

Jump to

Keyboard shortcuts

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