5

I am using the -cover to collect coverage in my Go project. However, it seems that the tests have to be 100% success rate in order to get the coverage report. Is there any way I can get the coverage despite the failed tests?

cxc
  • 201
  • 2
  • 10
  • 2
    Any value you get from `-cover` when tests fail, will be bogus anyway, since it will include any code that's executed by failing tests. – Jonathan Hall Dec 29 '22 at 17:07
  • What good is an inaccurate report? Why not skip failing tests so you can get a more accurate coverage report? – JimB Dec 30 '22 at 15:43
  • @JimB coverage is accurate it states how much of the code is covered by the test, which include test that fail. which is okay because even if tests fail the code is covered by the tests. – Pizza lord - on strike Jan 03 '23 at 10:57
  • Shouldn't there be use cases where we only ask for, say 90% of test success rate? And we want to know how much of that 90% have covered? Understandably that we might not want the failed tests to contribute to the overall coverage percentage. But can we get the coverage percentage of the passed tests at least? – cxc Jan 04 '23 at 16:20
  • You still do get a coverage profile when there are failing tests, so I'm not sure what else you want here. Whether it's useful or not is up to you. – JimB Jan 05 '23 at 17:27

0 Answers0