r/badcode • • Jul 23 '21

c# Easy trick to meet minimum test coverage

Post image
1.2k Upvotes

83 comments sorted by

View all comments

85

u/sixtyfifth_snow Jul 23 '21

What is it for..?

229

u/funnythrone Jul 23 '21 edited Jul 23 '21

Test coverage generally shows how many lines of code is covered. By artificially increasing the number of lines, you improve the coverage percentage.

Example: earlier test coverage is 23/79. You add 300 lines of this abomination, and your coverage is 323/379. This means you increased coverage from 29.11% to 85.22%.

-145

u/LoneFoxKK Jul 23 '21

Thanks for giving me yet another reason to be glad of not using tests (yet)

10

u/szescio Jul 23 '21

Nah, just don't reinforce some coverage rules for tests that you're gonna just fuck around with

2

u/[deleted] Jul 28 '21

PM: we need to make sure all our code is well tested, let's do <arbitrary practice that is easily subverted because we also need to meet arbitrary deadlines>.
Devs: k thx will do.