[go: up one dir, main page]

|
|
Log in / Subscribe / Register

Testing in Go: philosophy and tools

Testing in Go: philosophy and tools

Posted May 27, 2020 5:00 UTC (Wed) by tymonx (guest, #139151)
Parent article: Testing in Go: philosophy and tools

Recently I have been working on a project that allow to work on Go projects out-of-box using a Docker image: https://gitlab.com/tymonx/docker-go

It contains preinstalled tools for developing, mocking, formatting, linting, building, testing and documenting Go projects.

For mocking Go interfaces, I'm using the standard and classic mockgen tool in reflect mode. One of annoying thing about that tool is command line invocations. You manually provide a module name/path with interface names separate with comma.

I have scripted that to automatically and recursively detect all Go interfaces. It excludes _test.go files, mocks directories and the package main.

Go module detection is based on the go env GOMOD command invocation. All mocks are generated under the mocks directory for given Go package.

There are more features that can help. Like:
* Automatically generating JUnit test XML after tests
* Automatically generating Cobertura coverage XML after tests
* Validating Go coverage value threshold with colorization
* Colorizing Go coverage results and format nicely with the column tool
* Automatically generating static HTML coverage report with the go tool cover tool after tests


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds