testify-stats
is a drop in replacement for
testify that will print stats at the end
of the test suite:
$ go test -v
PASS
Tests: 460, Assertions: 1319, Time: 18.600047ms
ok github.com/elliotchance/testify-stats 0.014s
Note: The statistics will only print with the -v
option. This is because the testing package will capture all stdout and only print it under verbose more, or if there was a failure. I couldn't find a way around this. If you know of one, please let me know.
-
Swap all imports of
github.com/stretchr/testify/assert
withgithub.com/elliotchance/testify-stats/assert
. -
Either update or create a
TestMain
:
import "github.com/elliotchance/testify-stats"
func TestMain(m *testing.M) {
os.Exit(testify_stats.Run(m))
}
- Run
go test
as normal.
To make sure all assertions are recorded you can add the following step to your build/CI:
$(exit $(grep -r '"github.com/stretchr/testify"' . --include \*.go | wc -l))