You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The go install command doesn't pick up structs and functions which are defined in source file with names xxx_test.go
I know go test command uses _test.go files as part of the built in testing framework. In case I am building a lib, and I write tests in _test.go files (define some functions etc.) and run them from package main, but at present those definitions won't be visible and go install throws an error: undefined: TypeName
Is it possible that go install/build can be trained to throw a more verbose error message: For example: Definition found in xxx_test.go, please change the file name to something other than xxx_test.go
The text was updated successfully, but these errors were encountered:
_test.go files are not included in coverage. Fine but is it possible that go install/build can be trained to throw a more verbose error message? For example: Definition found in xxx_test.go, please change the file name to something other than xxx_test.go
mikioh
changed the title
Types and Functions defined in _test.go files are not visible/exported
cmd/go: Types and Functions defined in _test.go files are not visible/exported
Mar 18, 2015
Apparently this issue has the side effect of resulting in inconsistent test runs whether you run go test against a relative path (like ./...) or an absolute (import-like) path, like github.com/user/pkg.
Namely, if you run go test ./..., and your test files live in package foo_test, and they import foo, but they rely on something exported under *_test.go files (a common example is theexport_test.go, like the one in pkg fmt), go test will import the package from $GOPATH, not from wherever go test ./... is run (which makes sense). However, as @faizoff mentioned, the *_test.go files are not included in those builds (not even in tests builds, when the package being tested is other than the package that is imported, minus the _test suffix).
This usually never happens because people tend to run go test ./... while they're in the source tree. However, it does happen with the new Wercker Ewok, which runs Go tests in a different directory (/pipeline/source). This results in CI tests that use go test ./... failing, while CI tests that use go test github.com/user/pkg/... are passing.
Go version 1.4.2 release
OS: Linux amd64
The go install command doesn't pick up structs and functions which are defined in source file with names xxx_test.go
I know go test command uses _test.go files as part of the built in testing framework. In case I am building a lib, and I write tests in _test.go files (define some functions etc.) and run them from package main, but at present those definitions won't be visible and go install throws an error: undefined: TypeName
Is it possible that go install/build can be trained to throw a more verbose error message: For example: Definition found in xxx_test.go, please change the file name to something other than xxx_test.go
The text was updated successfully, but these errors were encountered: