If I run the following
go test -run NotExist
The response is PASS. Seeing as my test file does not contain a test called TestNotExist
Without the -run
option go test
runs all tests. You use the -run
option to not run all tests; to filter out, to exclude tests (and you do this in the form of requiring names of non-excludable tests to match a regexp pattern - but this is irrelevant form the point of discussion):
Command go, Test packages:
By default, go test needs no arguments. It compiles and tests the package with source in the current directory, including tests, and runs the tests.
Description of testing flags:
-run regexp Run only those tests and examples matching the regular expression.
It is a perfectly "normal" outcome that a filtering filters out all tests, that no tests remains in the set of tests that still need to be executed.
When no tests FAIL, it is considered as the test run PASSes. If no tests match, no tests will run and no tests will FAIL, and thus the test run will PASS.