Problem: We’re working in a Go monorepo. I’ve been writing tests for one package in one service in said monorepo. When I run
godep go test ./directoryofinterest
,
I get the following (positive) message:
ok github.com/path/to/my/directoryofinterest 0.019s
.
When I run
godep go test ./directoryofinterest -v
,
I get several failure messages in the main part of the output, and the last two lines are
FAIL
and
ok github.com/path/to/my/directoryofinterest 0.021
.
This is definitely some unexpected behavior.
Working through some of the 11th chapter of The Go Programming Language has surfaced a few idiosyncrasies.
- Running
go test
from the directory where the tests are returns 2 lines, whereas runninggo test ./directoryofinterest
from one directory up returns only one line. -
When you get the 2 lines, one is a
PASS
orFAIL
message, and the second is theok
message.
BUT WHYYYY???
Fun fact: it’s because i”m using an old version of Data Dog’s sqlmock.
After updating sqlmock to the current version, I get the expected behavior when running the tests.
Running the go test ./directoryofinterest
now returns 1 line when tests pass with the ‘ok’ message. Running the same command with failing tests returns multiple lines with the details of the failure, and the final line contains the FAIL message.