I have a Go project in which I'm using glide
for package management.
I have a test suite setup using godog
, which I run with go test
using a TestMain
wrapper as described in the docs of godoc
(with format pretty
).
Since I don't want to test packages I am vendoring, I call the tests with
go test $(glide novendor)
In my case, the project is very simple, and glide novendor
just returns a .
Now my question is: Why is it that when running go test
, I get a lot of pretty output, listing scenarios and steps and whatnot, but when I run go test .
I just get a one-liner
ok gitlab.knf.local/ngs/gpp 0.015s [no tests to run]
(This doesn't change even if I add a dummy test).
The output is different because this is how the Go tool is written. This is the intentional, default behavior.
If you just run go test
without listing packages, it will test the package in the current directory:
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.
If you list packages to go test
(may it be just a single package or just a .
, doesn't matter), then go test
will test all listed packages.
If you test a single package, you want to see the details and result of each tests. If you test multiple packages, normally you're not interested in the details of each individual tests, because that would just clutter your screen, and as information scrolls through your screen, you would not even notice if a test or a package fails. When testing multiple packages, normally you're just interested in the final result for each package. One line per package is a nice compromise and gives a clear result.
If you still want to see more verbose output when listing packages, simply pass the -v
flag:
go test -v $(glide novendor)
For more details and options, run go help test
, and/or visit the Command go documentation page, specifically sections Test packages and Description of testing flags.