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
Eric DelgadoEric Delgado 

Deployment from sandbox to production validation error

Hi,
I am trying to deploy from sandbox to production. However I keep getting validation errors. 
 
Code Coverage Failure
Your organization's code coverage is 4%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage. SOSCreateCaseCustom
 
User-added image

However, I already created a unit test for it. Does anyone know how to get over this issue? Thanks.
Best Answer chosen by Eric Delgado
Mahesh DMahesh D
Hi Eric,

Whenever you want to deploy any Apex Components(Apex Class / Apex Trigger) from Sandbox to Production, the average code coverage should be 75% and every Apex Class / Trigger should have minimum 1% code coverage.

Make sure that you have enough code coverage for all your classes and trigger. In your scenario 'SOSCreateCaseCustom' trigger doesn't have code coverage orelse you are not including the Test Class as part of the deployment.

I am sure you may be having the Test Class but not including in the change set, please include it and it will be done.

Please do let me know if this helps you.

Regards,
Mahesh

All Answers

venkat-Dvenkat-D
Eric,
In sandbox do Run all tests to get approximate code coverage. If the trigger you wrote is covered, that means other existing triggers do not have coverage. 
Mahesh DMahesh D
Hi Eric,

Whenever you want to deploy any Apex Components(Apex Class / Apex Trigger) from Sandbox to Production, the average code coverage should be 75% and every Apex Class / Trigger should have minimum 1% code coverage.

Make sure that you have enough code coverage for all your classes and trigger. In your scenario 'SOSCreateCaseCustom' trigger doesn't have code coverage orelse you are not including the Test Class as part of the deployment.

I am sure you may be having the Test Class but not including in the change set, please include it and it will be done.

Please do let me know if this helps you.

Regards,
Mahesh
This was selected as the best answer
Eric DelgadoEric Delgado
I just realized my unit tests failed even though it shows Success when I run it. I will start a new post for help on the unit testing since it is unrelated to this post.

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000DAGdIAO#!/feedtype=SINGLE_QUESTION_DETAIL&dc=Developer_Forums&criteria=OPENQUESTIONS&id=906F0000000DAGxIAO

Thanks.