How do I have go test several/packages/...
stop after the first test failure?
It takes some time to build and execute the rest of the tests, despite already having something to work with.
As part of building a test binary, go test runs go vet on the package and its test source files to identify significant problems. If go vet finds any problems, go test reports those and does not run the test binary.
By default, Jest runs all your tests and shows their result in the console. Yet, Jest comes with a bail option allowing you to stop running tests after n failed tests. You may configure the bail option to a boolean value or a number. Using a boolean for bail will either stop or not stop after the first failed test.
The testing package provides support for automated testing of the Golang code. To run any test function use “go test” command, which automates the execution of any function of the form TestXxx(*testing. T), where Xxx must not start with any lowercase letter. Test Function Syntax : func TestXxx(*testing.T)
At the command line in the greetings directory, run the go test command to execute the test. The go test command executes test functions (whose names begin with Test ) in test files (whose names end with _test.go). You can add the -v flag to get verbose output that lists all of the tests and their results.
Go 1.10 add a new flag failfast
to go test:
The new go test -failfast
flag disables running additional tests after any test fails. Note that tests running in parallel with the failing test are allowed to complete.
https://golang.org/doc/go1.10
However, note this does not work across packages: https://github.com/golang/go/issues/33038
Here's a workaround:
for s in $(go list ./...); do if ! go test -failfast -v -p 1 $s; then break; fi; done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With