Skipping tests
You can skip certain tests based on an input flag. This feature lets you have a quick test where only a subset of the tests are run and a comprehensive test where all the tests are run.
How to do it...
- Check the
testing.Short()
flag for tests that should be excluded from short test runs:func TestService(t *testing.T) { if testing.Short() { t.Skip("Service") } ... }
- Run tests with the
test.short
flag:$ go test -test.short -v === RUN TestService service_test.go:15: Service --- SKIP: TestService (0.00s) === RUN TestHandler --- PASS: TestHandler (0.00s) PASS