I want to create a package in Go with tests and examples for the package as subdirectories to keep the workspace cleaner. Is this possible and if so how?
All the docume
EDITED
Built on VonC's answer,
This answer is valid in go1.11
. No yet tested in upper go
versions.
For those of you who like to keep their tests in a sub-folder, say test
, then running
go test ./...
will attempt to run tests in every folder, even those that do not contain any test, thus having a ?
in the subsequent report for non-test folders.
Running
go test ./.../test
instead will target only your test
folders, thus having a clean report focused on your tests folders only.
CAUTION
Please be mindful that using test sub-folders will prevent coverage report computation. The phylosophy of go is to leave test files in the package folders.