Search⌘ K

Building the Foundation for End to End Tests

Explore how to establish a clear structure for end-to-end tests in Go command-line applications. Learn to centralize e2e tests in a dedicated directory and apply testing tools like Ginkgo and Gomega for efficient test management and cleanup.

Locating end-to-end tests

In Go, unit tests reside in the directory of the package they test. Where should you put end-to-end tests? For a command-line program like multi-git that has a single command called mg in the cmd directory, it makes sense to place the end-to-end tests there:

├── multi-git
│   ├── cmd
│   │   └── mg

However, I think of end-to-end tests as a separate entity that is not embedded with the code it is testing. The whole concept of black-box testing and testing from the outside suggests that testing in different locations is better. Also, in larger systems, there will be many artifacts, services, ...