I'm learning Go through writing a web app with the following structure
myapp/
db/
dbconf.yml
migrations/
*.sql
handler
modulea.go
moduleb.go
model
init.go
modulea.go
moduleb.go
myapp.go <-- this is my main package with main func
I added my some tests for the modulea in a file myapp_test.go
on project root, I want to organize the tests by module but I dont know how-to
You should place the tests for modulea
in a file called modulea_test.go
in the same folder and package as modulea
.
Unit tests should be tested in the same package as the functions being tested.
Then to test it you can do go test ./...
which will execute the tests for every package in your app.