On Thursday 15 February 2024 at 10:31:40 am UTC+11 Jeremy French wrote:

I really think the testability issue is the biggest one.  Generally, 
testing the main package is....cumbersome at least.  So it's reasonable to 
say, "I'm not going to test the main package, but I will keep it so simple 
that it is impossible for a bug to exist in there."  Then everything else 
in your application can be easily and thoroughly tested with the built-in 
testing tools


Yeah I've seen this before as well when there is a lot crammed into `func 
main()`. AFAICT anything that's in main *function* is only testable by 
building the binary and running it. If code is outside of the main function 
but still in the main package, it seems its testable like other functions? 
I suspect though if one is putting tests in package main_test, then I guess 
you can't import the main package to test it :( I generally keep my tests 
in the same package as the code they are testing, so hasn't been a problem 
*yet*. 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ab3d71ca-d6ad-4ca6-a772-1724375bb680n%40googlegroups.com.

Reply via email to