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
RimaRima 

Problem with the test coverage

Hi All,

 

I want to deploy an Apex class from sandbox to Enterprise Edition.When I run test under sandbox environment , I am getting following output.

 

Test failures:0,

Code coverage total %: 100

 

However, when I deploy that apex class to Enterprise Edition it is saying code coverage is only 54%. I am getting the following error.

Error: Average test coverage across all Apex Classes and Triggers is 54%, at least 75% test coverage is required

 

I am not understanding why coverage is 54% here?  Could anyone please explain me about this? Your help is greatly appreciated.

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
NeilJWNeilJW

Rima,

I just experienced a similar situation where my code coverage dropped from 100% to 20%. After doing much research I discovered it was because there was some data being referenced by my code that didn't exist in production (I had done the setup work on test but forgotten to on production). Perhaps there is a field, object or even a record of data that is needed that exists in test but not in production?

 

Neil