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
TaruniTaruni 

Difference in code coverage in sandbox and Production

 

Hi,

The issue is that I deployed a Trigger and Test class in Production from one of our sandbox.
In sandbox code coverage for that trigger is 62% (107/170) and the same in production is showing as only 42% (107/249).

Version in sandbox and prod is 20.0 for both the Trigger and Test class.
If you could observe there is a difference in the total number of lines in both the environments.
I have checked in production to know the difference so I found that its because in production its showing even commented lines and flower braces as not covered.

Any help will be much appreciated!

Tejpal KumawatTejpal Kumawat

Hi,

 

Move updated trigger & test Class or also you can check by copy production code into sandbox & then run test class.

Suresh RaghuramSuresh Raghuram

you are saying that trigger is already in the prod , but the code coverage is less than 75%, Here you need to remember one thing,

 

Unless the trigger and the test class have 75% code coverage it cannot be moved into prod.

 

The code coverage varies between sandbox and Prod because in Prod it will show you the over all code coverage not just only one Trigger.

Even if you have doubt check do you need to cover any negative scenarios.

 

 

Ryan DRyan D

If you have lines that are not covered and the are comments or curly braces you have to click "Clear code coverage" and then run the test again.  If you add new lines to your code after running a test the blue and red lines will remain on the same  line until you clear code coverage.