I have a function main()
in main.go that does the job and all other functions are below it (I did not include them here). So, when I write tests for all funcs
that are included in main
, I can test them. But the code coverage is low because it shows that I did not cover code from my main
func.
I know that there is a TestMain
func in the testing library that should do the job, but I just cannot get how to get it to work so that the tests cover func main()
.
Below is my main()
func which is not covered by tests...
func main() {
c, err := getConfig()
if err != nil {
log.Fatal(err)
}
slideshows, err := getSlideshows(c)
if err != nil {
log.Fatal(err)
}
displaySlideshows(slideshows)
}
Also, I did not find much about it on the internet, so, if this is a stupid question, please, explain to me why this is such a dum problem and where I should search for solutions!
I will appreciate any help!