Consider a multi binary project with the following structure.
.
├── bin1
│ ├── config
│ │ ├── config.go
│ │ └── config_test.go
│ └── utils
│ ├── utils.go
│ └── utils_test.go
├── bin2
│ ├── config
│ │ ├── config.go
│ │ └── config_test.go
│ └── utils
│ ├── utils.go
│ └── utils_test.go
├── cmd
│ ├── bin1
│ │ └── bin1.go
│ ├── bin2
│ │ └── bin2.go
│ └── bin3
│ └── bin3.go
├── go.mod
├── go.sum
└── shared
├── db
│ ├── db.go
│ └── db_test.go
├── model
│ ├── modela.go
│ ├── modela_test.go
│ ├── modelb.go
│ └── modelb_test.go
└── utils
├── utils.go
└── utils_test.go
This project has three binaries bin1
, bin2
and bin3
. Packages in the /shared
directory (e.g. package shareddb
, sharedmodel
and sharedutils
) are shared with binary specific packages (e.g. package bin1config
, bin1utils
in /bin1
directory and package bin2config
, bin2utils
in /bin2
directory).
How can we run
all the unit tests in this project altogether?
all the tests in a package (e.g. in
shared/model
)?each tests separately?
I attempted the following.
- Running
go test
from the project root resulted inno Go files in /projectroot
.