+ Start a Discussion
Amitkumar15Amitkumar15 

Code Coverage varies from one environment to another environment

 

Why Overall code coverage varies from one environment to another environment?

 

nathaForcenathaForce
Hi Amitkumar15,

A simple reason would be because the 2 orgs are not in sync: some test classes are implemented in sandbox, but were not moved to UAT or Prod yet.

More difficult to find would be if your test class relies on data (for example custom settings), which exists in one org but not another.
Lets say org A has a custom settings with data, and org B has the same custom settings with no data. Let's add that a test class relies on data being present for the test class to validate. The test class will fail in org B, and thus impact the code coverage %.

Hope that helps
Nathalie
Amitkumar15Amitkumar15

Thanks for replying Natha.

 

But my 2 org are in sync and this happens always when we move code from dev to uat or test,Always overall code coverage varies across environment.

 

Any other help on this?

nbknbk

The varience of the code coverage might be Configuration data from org to org.

 

Usually the developer environment the code coverage high and accurate (for ex class have 85%)

when you moved to class to package orgs (approximatly the coverage will down to 80) it is due to configurations and data related on the org.

For example you written one SOQL statement to retreive config item, the package org you don't have the configuration where as the config item have in Developer org.

 

ex code: list<ConfiguartionSettings> lst =[select id,name from configurationsettings where name='testkey'];

if(lst.size()>0)

{

  ///execute sample code

}

 

the 'testkey' is created in Developer org but not in Package org, due to these type of configurations and other areas the Code coverage wil show varaience.

 

 

 

 

Satish_SFDCSatish_SFDC
There might be some extra packages installed on any of your orgs. This may be lead to some extra code lines thereby changing the coverage %

Regards,
Satish Kumar