You need to sign in to do that
Don't have an account?
Melanie Miller 11
Code Coverage failure on trigger deployment
I have a trigger and associated test class that I am trying to deploy in production. Everything tests fine in the sandbox, and it says my trigger has 100% coverage there as well. But when I try to deploy the change set in production, I get a code coverage failure message of "The following triggers have 0% code coverage. Each trigger must have at least 1% code coverage." It then lists the new trigger as the only item with the problem.
My question is, why does my trigger have 100% coverage in the sandbox, but when I bring it into production is says it has 0%? I'm pretty new to this stuff, so this is really confusing. Any help would be very appreciated!
My question is, why does my trigger have 100% coverage in the sandbox, but when I bring it into production is says it has 0%? I'm pretty new to this stuff, so this is really confusing. Any help would be very appreciated!
Did you include the test class in your ChangeSet while deploying the trigger ? It is necessary to include the test class.
Also while deploying the trigger select the "run specified tests" option and write the name of your test class in the box provided below.
I'm not sure what might be causing the issue but just go through the steps mention in this link.
https://help.salesforce.com/apex/HTViewSolution?urlname=Code-coverage-steps-and-considerations-prior-to-deployments
What I'm trying to accomplish is saving the Opportunity stage value (when a related Opp exists) into a custom field I've created on the event object, at the time a new event is created.
Trigger Test Class
It looks like the test class is causing the code coverage failiure as you have used static id on line number 12.
Also you need to modify your trigger as we should avoid SOQL inside for loops. Try using this modified trigger:
Trigger