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
Sumant HegdeSumant Hegde 

Code Coverage Failure error in the production deployment

Hi, I have written 4 triggers and test classes for those triggers in sandbox. It shows "Your overall code coverage is currently 100%". But when I try to deploy it in the production, I am getting the following error
"Code Coverage Failure:
Your organization's code coverage is 0%. 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."

Any help would be highly appreciated.
Best Answer chosen by Sumant Hegde
Sumant HegdeSumant Hegde
Hi, 
We figured out the issue. It was a very silly mistake from our side. We were not deploying the test scripts along with the triggers that is why it was failing. When we deployed the trigger and the test script in the production. It worked.

Thanks for your suggestions though.

All Answers

Jamien Johnson 4Jamien Johnson 4
i have also detected the error with regards to the coverage of code on my system almost 2 weeks ago and it wasn't at all progressing after that so, I thought that as my system was also parallely slow and freezing all the time, it might be signalling a virus attack hence, I approached all the way to Avast Customer Care (https://antivirussupports.info/avast-customer-supports/) who did a thorough check and cleansed by system entirely but the problem with the code was checked and still found there. I ma tensed now. Can anyone help me out?
Steven NsubugaSteven Nsubuga
This usually means that some tests on production are currently failing.
Log into production and run all tests, if they pass then the issue is that while your tests pass in the sandbox, they fail in production. This usually happens due to hardcoding of record IDs, or the reliance of your tests on existing data in Salesforce. It might also happen if your tests use some objects that are not yet deployed to production, or when the objects do exist there but were modified in the sandbox and do not exactly match what is in production.
Sumant HegdeSumant Hegde
Thanks for your comments. @Steven: I will try to check all the fields and records in production and see what exactly is the issue.
Sumant HegdeSumant Hegde
Hi, 
We figured out the issue. It was a very silly mistake from our side. We were not deploying the test scripts along with the triggers that is why it was failing. When we deployed the trigger and the test script in the production. It worked.

Thanks for your suggestions though.
This was selected as the best answer