+ Start a Discussion
Nicole SackinNicole Sackin 

Code Coverage Failure: Problem with Apex trigger when I try to validate it in my production environment.

I have created an Apex trigger in my sandbox environment but I am receiving an error message when I try to validate it in my production environment. It is saying
Code Coverage Failure.
Your organization's code coverage is 73%. 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.
Best Answer chosen by Nicole Sackin
Andrew GAndrew G
Do a run all tests.  
Find the class with the worst coverage.
Find it's test class and rewrite / adjust as required to increase your test coverage for that class.
Include the updated test class in your deployment.

regards
Andrew

All Answers

VinayVinay (Salesforce Developers) 
Hi Nicole,

Every trigger must have some test coverage.  Try to compile and run related test classes.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_code_coverage_best_pract.htm

Thanks,
Vinay Kumar
Andrew GAndrew G
Do a run all tests.  
Find the class with the worst coverage.
Find it's test class and rewrite / adjust as required to increase your test coverage for that class.
Include the updated test class in your deployment.

regards
Andrew
This was selected as the best answer