Bizarre News

Enterprise Code Coverage – The Daily WTF


Alice has the dubious pleasure of working with SalesForce. Management wants to make sure that any code is well tested, so they’ve set a requirement that all deployed code needs 75% code coverage. Unfortunately, properly configuring a code coverage tool is too hard, so someone came up with a delightful solution: just count how many lines are in your tests and how many lines are in your code, and make sure that your tests make up 75% of the total codebase.

Given those metrics, someone added this test:

public void testThis() {
    int i = 0;
    i++;
    i++;
    i++;
    i++;
    i++;

    

    i++;
    i++;
    i++;
    i++;
}

Keep adding lines, and you could easily get close to 100% code coverage, this way. Heck, if you get close enough to round up, it’ll look like 100% code coverage.

[Advertisement] Plan Your .NET 9 Migration with Confidence
Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!


#Enterprise #Code #Coverage #Daily #WTF

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Close
Back to top button