You need to sign in to do that
Don't have an account?
Travis Hendrix
The following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.
I have a trigger here is its code:
I have a bunch of test classes that insert a quote but it still says 0% coverage. I have tried deploying the test class and then the trigger or the trigger and test class at the same time and still the same error. I finally wrote the following test just to cover the trigger:
trigger QuoteTrigger on Quote (before insert, before update, before delete, after insert, after update, after delete, after undelete) { QuoteTriggerHandler qth = new QuoteTriggerHandler(); if (Trigger.isBefore) { if(Trigger.isInsert){ qth.OnBeforeInsert(Trigger.new); } else if(Trigger.isUpdate){ qth.OnBeforeUpdate(Trigger.old,Trigger.new,trigger.newMap, Trigger.oldMap); } else if(Trigger.isDelete){ qth.OnBeforeDelete(trigger.old,Trigger.newMap, Trigger.oldMap); } } else if (Trigger.isAfter) { if(Trigger.isInsert){ qth.OnAfterInsert(Trigger.new,trigger.newMap); } else if(Trigger.isUpdate){ qth.OnAfterUpdate(Trigger.old,Trigger.new,trigger.newMap, Trigger.oldMap); } else if(Trigger.isDelete){ qth.OnAfterDelete(trigger.old,Trigger.newMap, Trigger.oldMap); } } }When trying to deploy it from the sandbox to production I get the error: The following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.
I have a bunch of test classes that insert a quote but it still says 0% coverage. I have tried deploying the test class and then the trigger or the trigger and test class at the same time and still the same error. I finally wrote the following test just to cover the trigger:
@isTest public with sharing class QuoteTriggerTest { public QuoteTriggerTest() {} @isTest static void Test_QuoteTrigger(){ Test.startTest(); CreateSobjectForTesting coft = new CreateSobjectForTesting(); Account a = (Account)coft.CreateObject('Account'); insert a; Opportunity o = (Opportunity)coft.CreateObject('Opportunity'); o.AccountId = a.id; o.Contact_Email__c = 'test@test.com'; o.Modified_ARR__c = False; o.Manager__c = 0; insert o; Product2 prod = (Product2)coft.CreateObject('Product2'); insert prod; Id pricebookId = Test.getStandardPricebookId(); PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = pricebookId, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true); insert standardPrice; Quote q = (Quote)coft.CreateObject('Quote'); q.OpportunityId = o.id; q.Eval_Days__c = '3'; q.PriceBook2Id = pricebookId; insert q; Test.stopTest(); } }I still get the same error. This is happening for 2 different triggers.