gitmyhub

goconvey

Go ★ 8.4k updated 1y ago

Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.

GoConvey is a Go testing tool that lets you write tests as readable plain-English sentences and adds a browser dashboard that auto-reruns tests on file changes and shows live coverage results.

Gosetup: easycomplexity 2/5

GoConvey is a testing tool for Go programs. It works alongside Go's built-in testing system rather than replacing it, so you can use it on existing projects without changing how tests are run.

The main thing GoConvey adds is a way to write tests that read more like sentences. Instead of just calling a function and checking if the result equals some value, you wrap the test logic in nested blocks that each have a plain-text description. The outer block might say "Given some integer with a starting value," an inner block says "When the integer is incremented," and the innermost block says "The value should be greater by one." When tests run, these descriptions appear in the output, making it easier to understand what failed and why.

GoConvey also ships a small local web server that you can run alongside your code. Once started, it watches your project for file changes and re-runs tests automatically. The results show up in a browser tab with a visual display of which tests passed and failed, including code coverage. The web interface works with ordinary Go tests too, not just tests written in GoConvey's style.

In the terminal, using GoConvey is no different from running any other Go tests. You run the usual "go test" command and get colored output. Optional desktop notifications can alert you when tests finish.

Installation is a single command using Go's package manager. The project currently supports Go 1.16 and 1.17. SmartyStreets, the company that created it, maintains the project on a best-effort basis and notes in the README that they may not address enhancement requests. The source code and documentation are publicly available on GitHub.

Where it fits