A nicer test runner for golang.
We've all been there... a bunch of tests failing and you have no idea where to start, because everything looks the same. And that one test failing in the sea of passing tests? So frustrating. Not anymore!
With bolt
you'll see a progress output while tests are being executed. Once
tests are done, you'll see an output with only the tests that failed. Simple and
easy!
Here's the before and after:
Features:
- Colored output
- Dotenv files support
- Coverage output
- Slowest tests output
- Benchmark output
Download the binary for your system from the
latest release and place it
anywhere on your path (you'll need to make it executable with chmod +x
).
bolt wraps go test
. You can run it with:
$ bolt run ./...
Options:
$ bolt -h
bolt is a golang test runner that has a nicer output.
Usage: bolt [command] [options]
Commands:
bolt version Show bolt version
bolt run Run tests
bolt update Update to the latest released version
bolt [command] --help Display help on [command]
Further information:
https://github.com/fnando/bolt
To get the latest download url for your binary, you can use bolt download-url
.
bolt comes with two different reporters:
The JSON reporter outputs a nicer JSON format that can be used to do things that require structured data.
$ bolt run ./... --reporter json
The progress reporter outputs a sequence of characters that represent the test's status (fail, pass, skip). Once all tests have been executed, a summary with the failing and skipped tests, plus a coverage list is printed.
$ bolt run ./... --reporter progress
You can override the colors by setting the following env vars:
export BOLT_TEXT_COLOR="30"
export BOLT_FAIL_COLOR="31"
export BOLT_PASS_COLOR="32"
export BOLT_SKIP_COLOR="33"
export BOLT_DETAIL_COLOR="34"
To disable color output completely, just set NO_COLOR=1
.
To override the characters, you can set some env vars. The following example shows how to use emojis instead:
export BOLT_FAIL_SYMBOL=❌
export BOLT_PASS_SYMBOL=⚡️
export BOLT_SKIP_SYMBOL=😴
You can run any commands after the runner is done by using --post-run-command
.
The command will receive the following environment variables.
BOLT_SUMMARY:
a text summarizing the testsBOLT_TITLE:
a text that can be used as the title (e.g. Passed!)BOLT_TEST_COUNT:
a number representing the total number of testsBOLT_FAIL_COUNT:
a number representing the total number of failed testsBOLT_PASS_COUNT:
a number representing the total number of passing testsBOLT_SKIP_COUNT:
a number representing the total number of skipped testsBOLT_BENCHMARK_COUNT:
a number representing the total number of benchmarksBOLT_ELAPSED:
a string representing the duration (e.g. 1m20s)BOLT_ELAPSED_NANOSECONDS:
an integer string representing the duration in nanoseconds
Everyone interacting in the bolt project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
To generate new test replay files, you can use
go test -cover -json -tags=reference ./test/reference/package > test/replays/[case].txt
.
To generate new benchmark replay files, you can use
go test -json -fullpath -tags=reference -bench . ./test/reference/bench &> test/replays/benchmark.txt
.
Once files are exported, make sure you replace all paths to use /home/test
as
the home directory, and /home/test/bolt
as the working directory.
You can run tests with ./bin/test
.
Bug reports and pull requests are welcome on GitHub at https://github.com/fnando/bolt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
This project is available as open source under the terms of the MIT License.