My project-structurestuff/stuff.go -> package: stufftest/stuff/stuff_test.go -> package: test
Although stuff_test executes code from stuff.go it showscoverage: 0.0% of statements
I used
go test -cover
If I move my *_test.go to the stuff-folder of the program it is working fine.
Or perhaps my approach of the project-structure is not well designed/go-conform?
Conventional Go program structure keeps the tests with the package. Like this:
project
|-stuff
|--stuff.go
|--stuff_test.go
At the top of your testing files you still declare package stuff, and it is required that your test methods take the form TestMethodX if you want go test to automatically run them.
See Go docs for details: https://golang.org/pkg/testing/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With