github.com/fnando/bolt@v0.0.4-0.20231107225351-5241e4d187b8/README.md (about) 1 <p align="center"> 2 <picture> 3 <source width="200" media="(prefers-color-scheme: dark)" srcset="https://github.com/fnando/bolt/raw/main/bolt-dark.png"></source> 4 <img width="200" src="https://github.com/fnando/bolt/raw/main/bolt-light.png" alt="Bolt: a nicer test runner for golang"> 5 </picture> 6 </p> 7 8 <p align="center"> 9 A nicer test runner for golang. 10 </p> 11 12 <p align="center"> 13 <a href="https://github.com/fnando/bolt/releases/latest"><img src="https://img.shields.io/github/v/release/fnando/bolt?label=version" alt="Latest release"></a> <a href="https://github.com/fnando/bolt/actions/workflows/tests.yml"><img src="https://github.com/fnando/bolt/actions/workflows/tests.yml/badge.svg" alt="Tests"></a> 14 </p> 15 16 We've all been there... a bunch of tests failing and you have no idea where to 17 start, because everything looks the same. And that one test failing in the sea 18 of passing tests? So frustrating. Not anymore! 19 20 With `bolt` you'll see a progress output while tests are being executed. Once 21 tests are done, you'll see an output with only the tests that failed. Simple and 22 easy! 23 24 Here's the before and after: 25 26 <picture> 27 <source media="(prefers-color-scheme: dark)" srcset="https://github.com/fnando/bolt/raw/main/bolt-screenshot-dark.png"></source> 28 <img src="https://github.com/fnando/bolt/raw/main/bolt-screenshot-light.png" alt="A screenshot showing the comparison between the native output versus bolt's"> 29 </picture> 30 31 Features: 32 33 - Colored output 34 - Dotenv files support 35 - Coverage output 36 - Slowest tests output 37 - Benchmark output 38 39 ## Install 40 41 Download the binary for your system from the 42 [latest release](https://github.com/fnando/bolt/releases/latest) and place it 43 anywhere on your path (you'll need to make it executable with `chmod +x`). 44 45 ## Usage 46 47 bolt wraps `go test`. You can run it with: 48 49 ```shell 50 $ bolt run ./... 51 ``` 52 53 Options: 54 55 ```shell 56 $ bolt -h 57 58 bolt is a golang test runner that has a nicer output. 59 60 Usage: bolt [command] [options] 61 62 Commands: 63 64 bolt version Show bolt version 65 bolt run Run tests 66 bolt update Update to the latest released version 67 bolt [command] --help Display help on [command] 68 69 70 Further information: 71 https://github.com/fnando/bolt 72 ``` 73 74 To get the latest download url for your binary, you can use `bolt download-url`. 75 76 ### Reporters 77 78 bolt comes with two different reporters: 79 80 ### JSON 81 82 The JSON reporter outputs a nicer JSON format that can be used to do things that 83 require structured data. 84 85 ```shell 86 $ bolt run ./... --reporter json 87 ``` 88 89 ### Progress 90 91 The progress reporter outputs a sequence of characters that represent the test's 92 status (fail, pass, skip). Once all tests have been executed, a summary with the 93 failing and skipped tests, plus a coverage list is printed. 94 95 ```shell 96 $ bolt run ./... --reporter progress 97 ``` 98 99 #### Overriding colors 100 101 You can override the colors by setting the following env vars: 102 103 ```bash 104 export BOLT_TEXT_COLOR="30" 105 export BOLT_FAIL_COLOR="31" 106 export BOLT_PASS_COLOR="32" 107 export BOLT_SKIP_COLOR="33" 108 export BOLT_DETAIL_COLOR="34" 109 ``` 110 111 To disable color output completely, just set `NO_COLOR=1`. 112 113 #### Overriding symbols 114 115 To override the characters, you can set some env vars. The following example 116 shows how to use emojis instead: 117 118 ```shell 119 export BOLT_FAIL_SYMBOL=❌ 120 export BOLT_PASS_SYMBOL=⚡️ 121 export BOLT_SKIP_SYMBOL=😴 122 ``` 123 124 ### Post Run Command 125 126 You can run any commands after the runner is done by using `--post-run-command`. 127 The command will receive the following environment variables. 128 129 - `BOLT_SUMMARY:` a text summarizing the tests 130 - `BOLT_TITLE:` a text that can be used as the title (e.g. Passed!) 131 - `BOLT_TEST_COUNT:` a number representing the total number of tests 132 - `BOLT_FAIL_COUNT:` a number representing the total number of failed tests 133 - `BOLT_PASS_COUNT:` a number representing the total number of passing tests 134 - `BOLT_SKIP_COUNT:` a number representing the total number of skipped tests 135 - `BOLT_BENCHMARK_COUNT:` a number representing the total number of benchmarks 136 - `BOLT_ELAPSED:` a string representing the duration (e.g. 1m20s) 137 - `BOLT_ELAPSED_NANOSECONDS:` an integer string representing the duration in 138 nanoseconds 139 140 ## Code of Conduct 141 142 Everyone interacting in the bolt project’s codebases, issue trackers, chat rooms 143 and mailing lists is expected to follow the 144 [code of conduct](https://github.com/fnando/bolt/blob/main/CODE_OF_CONDUCT.md). 145 146 ## Developing 147 148 To generate new test replay files, you can use 149 `go test -cover -json -tags=reference ./test/reference/package > test/replays/[case].txt`. 150 151 To generate new benchmark replay files, you can use 152 `go test -json -fullpath -tags=reference -bench . ./test/reference/bench &> test/replays/benchmark.txt`. 153 154 Once files are exported, make sure you replace all paths to use `/home/test` as 155 the home directory, and `/home/test/bolt` as the working directory. 156 157 You can run tests with `./bin/test`. 158 159 ## Contributing 160 161 Bug reports and pull requests are welcome on GitHub at 162 https://github.com/fnando/bolt. This project is intended to be a safe, welcoming 163 space for collaboration, and contributors are expected to adhere to the 164 [Contributor Covenant](http://contributor-covenant.org) code of conduct. 165 166 ## License 167 168 This project is available as open source under the terms of the 169 [MIT License](https://opensource.org/licenses/MIT).