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
Pablo LamasPablo Lamas 

Code Coverage for Trigger is being evaluated as a class and not as a trigger.

Hello,
I currently having and issue with trying to deploy a fix to a trigger class that we have. When I validate it, I receive the following error: 
      Your code coverage is 8%. You need at least 75% coverage to complete this deployment.
The issue is that, this isnt a regular apex class, it is a trigger. From what I understand, triggers need to have >0% code coverage, which I have 8% code coverage. Any ideas as to why this is being evaluated at the 75% code coverage and not at the >0% code coverage. 
Best Answer chosen by Pablo Lamas
Kenneth Bowman 16Kenneth Bowman 16
Hi Pablo,

Even though an individual, particular trigger doesn't need more than 1% coverage, you still must have 75% complete code coverage for the entirety of the Org in order to deploy any apex. 

Best practice is to treat your trigger as though it is an Apex class and keep its code coverage above 75% individually, and strive for 100% coverage. 

Hope that helps!

 

All Answers

Kenneth Bowman 16Kenneth Bowman 16
Hi Pablo,

Even though an individual, particular trigger doesn't need more than 1% coverage, you still must have 75% complete code coverage for the entirety of the Org in order to deploy any apex. 

Best practice is to treat your trigger as though it is an Apex class and keep its code coverage above 75% individually, and strive for 100% coverage. 

Hope that helps!

 
This was selected as the best answer
Pablo LamasPablo Lamas
Oh I see! So it is not just calculating the percentage of the trigger I am trying to deploy but the Org as a whole. That makes more sense. In that case, I need to make sure more of my trigger is covered and that way the trigger can be pushed into production. Thank you Kenneth! I was going crazy trying to figure out why it was using the 75%.