Debug all tests when using modules

How can I debug all tests of a project when using Go modules?

Minimal example:

mkdir foo
cd foo
go mod init foo
# Then open with GoLand and add a default Go Test configuration
# for test-kind Directory and click on Debug

I get the error message

Error running 'go test foo': Cannot run compiling on directory-kind run configuration

I'm using GoLand 2021.1 for Mac.

1
3 comments
Official comment

Go cannot compile directory-kind run configurations (when you run go build on directory recursively) into a single binary, hence the debugging is not supported. You can change your run configuration to Package kind via Run | Edit configurations.

Avatar
Permanently deleted user

Daniil Thanks for the quick response. But with a run configuration of Package Kind I wouldn't be able to debug all tests if they are spread over multiple packages, would I? Sure it must be technically possible to do this. Should I create an issue for it, so that I get informed when that will be possible?

0

Thanks for the update.

You can debug a test across one current package. I'm not sure about the case where recursive debugging tests might help. Could you please elaborate a bit?

Sure it must be technically possible to do this.

GoLand uses Delve under the hood, and you can pass a single binary file to it, and architecture IDE supposes to run the single process per test run. go test ./.. (similar to test kind Directory) runs your tests recursively, and there is no compiled binary. That's why it's impossible for the debugger, but available for the regular test runs.

Should I create an issue for it, so that I get informed when that will be possible?

You can fill out a new ticket, but we need to have clear reasons and, probably, critical or important reasons to implement debugging for directories instead of compiled binaries. It requires a lot of effort and big changes in the IDEs architecture.

-1

Please sign in to leave a comment.