Skip to content

Collect code coverage while running Go-lang binary

Notifications You must be signed in to change notification settings

reconquest/go-test.bash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go test build

Helper for running integration tests for Golang apps with coverage.

go-test

Installation

Install gocovmerge first.

bash get github.com/reconquest/go-test

Usage

In main.go

var exit = os.Exit

All following exit's should be done via function exit.

Importing via imports.bash

import:use github.com/reconquest/go-test

Makefile (optional)

...

include vendor/github.com/reconquest/go-test.bash/Makefile

Building binary

# after import

go-test:set-output-dir "$(pwd)"
go-test:build <target-exe-name>

Running binary

# after import & build

go-test:run <target-exe-name> [<args>]

Compiling coverage

# after import & run

go-test:merge-coverage

Inspecting coverage

To open browser with coverage web-interface:

make coverage.html

To see text report:

make coverage.report

After that step coverage will be available at coverage.html file.

Limitations

Current implementation will not preserve error exit code (>0) and any exit code >0 will cause program to exit
with exit code of 1.

Program should end all it's goroutines correctly before calling exit. Otherwise, this implementation will hang in waiting goroutines to finish.

About

Collect code coverage while running Go-lang binary

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published