Description
Hi I am using gopls in VSCode and have the following issue/question detailed below. Hopefully, this is the correct place to report, if not please direct to correct place to submit query/issue.
What version of Go are you using (go version
)?
$ go version go1.15.7 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env O111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/really?/Library/Caches/go-build" GOENV="/Users/really?/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/really?/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/really?/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/really?/Development/Projects/Go/form3/accountapi-client/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/h5/k56b8xzj3cbbx4b3_rnmq2_00000gn/T/go-build062526535=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
I have implemented some integration tests using testify/suite. The tests in the test suite are split across files organised by feature as opposed to bunching them all together in one large file. I can confirm that the all tests in the suite run through the terminal using go test
command.
However, within VSCode the links for running and debugging each test are not displayed across all files that contain tests in the test suite:
- Declare the test suite struct and any test hooks (before, after etc.) in a separate source file, e.g.
testsuite.go
. - Create separate files for testing each feature: feature_1_tests.go, feature_2_tests.go etc. These contain the tests for the test suite organised by feature, e.g.:
feature_1_test.go
func (suite *IntegrationTestSuite) TestFeat1_MyTest {}
...
feature_2_test.go
func (suite *IntegrationTestSuite) TestFeat2_SeparateTest {}
...
- Declare function in feature_1_tests.go for running the test suite:
// TestIntegrationTestSuite for 'go test' to run this suite, we need to create
// a normal test function and pass our suite to suite.Run
func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}
Links for running and debugging the test are displayed in VSCode within go_feat1_integration_test.go. However, there are no links for creating and debugging tests displayed for the tests in file feature_2_test.go.
What did you expect to see?
It should be possible to see links for running and debugging tests across all files that contain tests for a test suite in VSCode. How to achieve this?
What did you see instead?
Run and debug links are only shown on the test file that contains the function to start the test suite:
// In order for 'go test' to run this suite, we need to create
// a normal test function and pass our suite to suite.Run
func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}