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
Elliott BullingElliott Bulling 

Code Coverage Shows 77% in dev console, but fails in validation of change set.

I have created a change set that I am trying to get to production. I created it initially in our partial sandbox and then sent it to our full sandbox. When I run APEX tests in the partial sandbox I show 77% coverage, when i try to validate the change set it shows 44% coverage. All the files that changed and the triggers and tests are included in the change set, yet it doesnt work. I then chose to not validate and deploy direct to the full sandbox. Once I did that I went to the dev console and tested the code again and it shows that class is 77% covered.

I then tried to go from full to production and got the same code coverage error showing 43% coverage, even though in the dev console, after clearing all test data and running again, that its at 77%.

Please tell me why there is this discrepancy when I know I am including everything I need to include ( based on the gitHub PR of files changed) and all the tests pass just like in the dev console.

 
Best Answer chosen by Elliott Bulling
Ajay K DubediAjay K Dubedi
Hi Elliott,

I'm not sure what might be causing the issue but just go through the steps mention in this link.
https://help.salesforce.com/apex/HTViewSolution?urlname=Code-coverage-steps-and-considerations-prior-to-deployments

Also, please make sure that you are not using any static id of a record in your test class.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com

All Answers

Ajay K DubediAjay K Dubedi
Hi Elliott,

I'm not sure what might be causing the issue but just go through the steps mention in this link.
https://help.salesforce.com/apex/HTViewSolution?urlname=Code-coverage-steps-and-considerations-prior-to-deployments

Also, please make sure that you are not using any static id of a record in your test class.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
This was selected as the best answer
Elliott BullingElliott Bulling
Running through those steps in that article to clear out the test data seems to have worked. Thanks Ajay