Running multiple tests within a package (terminal vs run configuration)

Completed

I am using Goland. I have the following package:

src/event

which has the files:

main_test.go, a.go,  and a_test.go

In main_test.go I have the init(), setUp(), tearDown() functions that a_test.go uses.

If I run from the Goland terminal with "go test *.go -v" it runs all my tests in a_test.go with the init(), setup(), and teardown() being called accordingly. So this works just fine.

How can I run this using Goland's run configuration? I have it set up as "Go Test" with the following:

Test framework: gotest

Test kind: Directory (where I have the src/event), and I've tried File (where I've tried main_test.go and *.go)

working directory: src/events

 

If I try to run with Directory it tells me that it can't load package: named files must be .go files: ./...

If I try to run with File and set the file to main_test.go I get: "no tests to run"

If I try to run with File and set the file to a_test.go I get an error because the global variables found in main_test.go are not being found.

If I try to run with File and set the file to *.go I can't even save the configuration because the file *.go isn't found.

 

I can run this from the terminal so I'm sure there is a way to run this through the run configuration. I can't run in debug mode until I solve this.

Thanks,

Regina

 

3 comments
Comment actions Permalink

Hello,

You can create a configuration by using a Right-click | Run | go test <dir name> in the GoLand (Click on Project Directory).

Is this option right for you? If not, do you have the opportunity to attach an example of your project (can be sent using this form)?

0
Comment actions Permalink

This did work, thanks. I'm not sure why selecting the directory in the tree structure and then "run->go test" works and trying to create a configuration doesn't, but this solves my problem. Thanks! :-)

0
Comment actions Permalink

Regina, I think that you can compare two configurations: your own and the one created automatically, then find the difference in them.

0

Please sign in to leave a comment.