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
lawlaw 

Strange code coverage issue

I have a class file that shows 100% coverage when I run its Test Class file.  However, when I attempt to deploy any new code this same class file only shows 57% coverage.  Anyone experience this type of issue or have a resolution?

Thanks in advance
Best Answer chosen by law
lawlaw
Shashank

I resolved this issue by updating the API on Class and test Class to the latest version.   After this it showed me the true code coverage and I was able to increase the code coverage enought to move the code into prod.

All Answers

ShashankShashank (Salesforce Developers) 
You should ensure that you are deploying the test class as well while deploying the apex class.

Also, I found a couple of similar known issues reported here, which you may want to check if you are indeed including test classes as well in your deployment:
https://success.salesforce.com/issues_view?id=a1p30000000T5k3AAC
https://success.salesforce.com/issues_view?id=a1p30000000T4oRAAS
lawlaw
I have tried including the test class with the deployment. Actually, Ive tried just redeploying the test class... and I still receive the code coverage error.
ShashankShashank (Salesforce Developers) 
Did you find any of the above known issues relevant?
lawlaw
No... those known issues did not resolve  my problem...
ShashankShashank (Salesforce Developers) 
Hi,

Could you please give me more detailed steps to replicate the issue so that I can try it out in my test org and check if the issue is replicable?

Thanks,
Shashank
lawlaw
Shashank

I resolved this issue by updating the API on Class and test Class to the latest version.   After this it showed me the true code coverage and I was able to increase the code coverage enought to move the code into prod.
This was selected as the best answer