FWIW, I did not know about this line: "Test files that declare a package with the suffix "_test" will be compiled as a separate package, and then linked and run with the main test binary."
In order to write integration/e2e tests while avoiding import cycles, most (not all) of our tests live in a dedicated "/tests" directory: https://github.com/ohsu-comp-bio/funnel/tree/master/tests Knowing about the line above, I think I'll encourage us to try to reorganize our tests back into the package structure and ditch the dedicated "/tests" directory. Might be too late for that though, for this project. -A On Tuesday, January 30, 2018 at 5:51:58 AM UTC-8, Stevo Slavić wrote: > > Hello Go community, > > Official docs recommend putting unit tests in same package as package > under test, see: > - https://golang.org/doc/faq#How_do_I_write_a_unit_test > - https://golang.org/pkg/testing/ > > Practical experience (see > https://medium.com/@matryer/5-simple-tips-and-tricks-for-writing-unit-tests-in-golang-619653f90742#03db) > > suggests it's better to put tests to a dedicated package so it can test > exported API only of the package under test, and if there's value to test > the package internals too then put another test suite file to the same > package with a special file name to make it clear it's meant to fiddle with > internals. > > Do these suggestions make sense? If so, would it make sense to make them > official recommended practice? Maybe in Effective Go? > > Kind regards, > Stevo Slavic. > -- 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. For more options, visit https://groups.google.com/d/optout.