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
Thue OlsenThue Olsen 

Code Coverage Error

Hello,
We are trying to deploy a change set for our client, but the validation keeps returning a Code Coverage Error with the following error message:
Details: Average test coverage across all Apex Classes and Triggers is 73%, at least 75% test coverage is required.
According to our developer the code coverage is 82% in the Developer Console.
Best Answer chosen by Thue Olsen
PratikPratik (Salesforce Developers) 
Hi Thue,

Please refer to this article:
https://help.salesforce.com/apex/HTViewSolution?urlname=Code-coverage-steps-and-considerations-prior-to-deployments&language=en_US

Thanks,
Pratik

All Answers

sandeep sankhlasandeep sankhla
Hi Thus,

Just go to your org and then setup--> then type classes and then there , there is a option to check coverall codecoverage adn there you will come to knwo the exact %

User-added image

If your changeset is not throwing any error then the overall coverage is less then 75%  and its throwing coverage error..

Please check and let me know ...

Thanks
PratikPratik (Salesforce Developers) 
Hi Thue,

Please refer to this article:
https://help.salesforce.com/apex/HTViewSolution?urlname=Code-coverage-steps-and-considerations-prior-to-deployments&language=en_US

Thanks,
Pratik
This was selected as the best answer
Thue OlsenThue Olsen
Hi Sandeep,
Under Apex Classes, I get the same code coverage of 82%.
"Code Coverage: 82%Your overall code coverage is currently 82%. To deploy code to production, you must have at least 75%."
Br,
Thue
 
sandeep sankhlasandeep sankhla
Hi Thus,

then just go through with teh link which Pratik has shared in above link..that will be helpful..

Thanks
praveen murugesanpraveen murugesan
Hi Thue,

I have faced the same problem. Reason for this is salesforce its taking old coverage its covers commented code, line spaces also. But while deploying coverage is calculating in a proper way. And there is way to fix this. For this you need to edit all the classes/controller not test classes in developer console so it will display exact coverage of class. And you need consider one thing if we edit all the classes it may reach api requets. So before edit pls monitor the total system api requests and remaining.

Thanks.
-- Praveen Murugesan.


Mark this solution if its solved your problem. So it may help others too.
PratikPratik (Salesforce Developers) 
Glad it helped!

Thanks,
Pratik