Easily measure code coverage of Golang binaries
Check out this blog post to see an example of Bincover is used, and how it works under the hood.
Package bincover provides an easy way to measure code coverage of Golang binaries. See examples/ to see how bincover is used to measure coverage of a simple Go application.
- func RunTest(f func())
- type CoverageCollector
- type CoverageCollectorOption
- type PostCmdFunc
- type PreCmdFunc
This section is empty.
var ( ExitCode = 0 )
func RunTest(f func())
RunTest runs function f (usually main), with arguments specified by the flag "args-file", a file of newline-separated args. When f runs to completion (success or failure), RunTest prints (newline-separated): 1. f's output, 2. startOfMetadataMarker 3. a testMetadata struct 4. endOfMetadataMarker
Otherwise, if an unexpected error is encountered during execution, RunTest panics.
type CoverageCollector ¶
func NewCoverageCollector ¶
NewCoverageCollector initializes a CoverageCollector with the specified merged coverage filename. CollectCoverage can be set to true to collect coverage, or set to false to skip coverage collection. This is provided in order to enable reuse of CoverageCollector for tests where coverage measurement is not needed.
func (c *CoverageCollector) RunBinary(binPath string, mainTestName string, env string, args string, options ...CoverageCollectorOption) (output string, exitCode int, err error)
RunBinary runs the instrumented binary at binPath with env environment variables, executing only the test with mainTestName with the specified args.
type CoverageCollectorOption ¶
type CoverageCollectorOption func(collector *CoverageCollector)