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
My particular scenario is exporting a test suite (like from testify) per package, so they can be run individually as unit tests, but also aggregated together for integration tests.
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
Test exports should be visible to tests in other packages
cmd/go: Test exports should be visible to tests in other packages
Jun 13, 2015
You can already simulate this with build tags.
Just put the test exports that need to be accessed
by other packages in a file guarded by "// +build test",
and use go test -tags test somepkg to test.
Thanks for the workaround. This would mean either (1) always using -tags test with go test, which isn't obvious, or (2) always using a make file to test. Neither are great for obvious reasons. Ideally this would be possible through a plain "go test" command.
Test exports should not be visible to tests in other packages. This is by design. What you expose for your own tests might be very different from what you want to expose for other clients, even clients writing tests.
Put another way, tests are only for the package author. Anything used by other packages is public API.
My particular scenario is exporting a test suite (like from testify) per package, so they can be run individually as unit tests, but also aggregated together for integration tests.
The text was updated successfully, but these errors were encountered: