How to show build errors in tests?

In my project

  • go build succeeds
  • go test fails with [build failed] with just a package name.

How can I see build errors in test files in general? Or at least in which file the error is?

As it is, all I can do is to open all files in the package in hope that IDE will highlight the error for me.

Can you show each command and the output? For example:

~/P/dotconfig (main|✔) $ go build
~/P/dotconfig (main|✔) $ go test
PASS
ok      github.com/DeanPDX/dotconfig    0.147s
~/P/dotconfig (main|✔) $

It depends on your testing framework and build system. In most cases, enabling verbose logging (--verbose or -v flags) and configuring your CI/CD pipeline to capture build output can help. Are you using Jest, Mocha, or another testing framework

go build -v gives no output
go test shows compile errors, but it doesn’t stop there, it executes all test which needlessly take time and results in potentially hunderds of lines about failed tests (which happens in the middle of development) which I don’t want to see.
go test -v is even worse because it also shows information about passed tests.

I use go.testing from stdlib 1.24.1 for tests and stretchr/testify for assertions.

For now I’m concerned about local development, I shouldn’t commit a code which doesn’t even compile, right?