function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ravi Kumar 259Ravi Kumar 259 

what is the use of code coverage? and Code coverage & Its importance .?

NagaNaga (Salesforce Developers) 
Hi Ravi,

Salesforce is 'multi-tenant' meaning that lots of companies and their users are hosted on the same physical platform as one-another. That being the case, its important that any custom code installed on the platform is robust. I believe the 75% mark is high enough to make you consider writing effective unit tests (though to be honest, it doesn't really enforce it) but not too high that you end up chasing 100% coverage when those final few %age points maybe too costly and time-consuming to achieve.

The 75% mark only really refers to test coverage, it doesn't really have anything to do with how effective your tests are, for example you may have a really bad test that does achieve 100% coverage. Consider this basic fictitious class whose job it is simply to create an Account called 'One'.

User-added image
But, what is this actually testing? Sure, it gets you the coverage but really to prove that the test worked, you would need to check that the Account was actually created - in code, i.e. by re-querying the results back from Salesforce and using System.assert you could really ensure that the Account One was created.

I would think you'll get quite a few answers on this subject, but in summary I feel that the 75% lower limit enforces you to put a reasonable amount of effort into your unit tests.

Best Regards
Naga Kiran