The /test
directory, also often named spec
, stores additional data and tools for automated testing.
Additional external test applications and test data. Feel free to structure the /test directory anyway you want. For bigger projects it makes sense to have a data subdirectory. For example, you can have /test/data or /test/testdata if you need Go to ignore what's in that directory. Note that Go will also ignore directories or files that begin with "." or "_", so you have more flexibility in terms of how you name your test data directory.
The layout always depends on the individual use case(s) of the project, but there are resources like the official documentations of the go test
command, which includes information about directories named testdata
, and about package lists and patterns.
test
├─ conformance
│ └─ testdata
├─ e2e
│ └─ testdata
├─ fixtures
│ └─ testdata
├─ functional
│ └─ testdata
├─ fuzzing
│ └─ testdata
├─ integration
│ └─ testdata
├─ migration
│ └─ testdata
├─ performance
│ └─ testdata
├─ specifications
└─ utils
└─ config
Next to the experience with own projects and golang-standards/project-layout, many other large, production-grade and well-known projects of the Go ecosystem have been used as references:
Blog posts, videos and documentations: