We are working on a project that requires some test helpers and mocks that, 
ideally, should:

- Helpers should be accessible by all testing code, unit tests, integration 
or e2e. 
      - Note unit tests live along side normal code in their *_test.go 
files.
      - The rest of tests will be on a separated test/ folder using a built 
tag to avoid to be compiled in with regular code.

- Helpers should not be part of the default exported module code.

- Helpers do not need to be accessible by the regular code, just the test 
code.

- Helpers might need tests themselves.

How can we achieve that in the simplest or cleanest way? We do not want to 
create yet another project for just that, as it is only to be used within 
this project.

I was thinking about a build tag for such code and just put it on a regular 
folder, such as testsupport/. But that would break unit tests that need 
that unless you setup the build tag, which feels weird.

Another option is to place the test support and the test that use them 
under the same build tag and folder as test/. And run them separately with 
the build tag. That creates a special category of unit tests, when they are 
not integration or e2e but need supporting code from those test/support/ 
packages.

Maybe use a module at testsupport/ separate from the rest of the code and 
use it as a library from test code?

Any better options?
Or maybe there is a good known solution for this I should know about.

Jose

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ca983d85-b5f5-423d-b949-71fa41b414ccn%40googlegroups.com.

Reply via email to