Testing in Go: philosophy and tools
Testing in Go: philosophy and tools
Posted May 26, 2020 22:33 UTC (Tue) by phlogistonjohn (subscriber, #81085)In reply to: Testing in Go: philosophy and tools by benhoyt
Parent article: Testing in Go: philosophy and tools
Here's an example of wrapping the main function in a test to get coverage.
I have to second Cyberax's comment. Last time I looked into this it quickly became too complicated to deal with, and I didn't need it very much and gave up. I too peeked at the code to implement this and it was too complex for me to follow (having been doing Go mostly full time for a year or so).
It's rather unfortunate that this isn't a feature of the compiler and say a helper module you can import into your own main. I lean heavily normal on the coverage feature for tests in a few of the projects I work on. I would love to have a simple, noninvasive way to generate coverage from any binary.