+ Start a Discussion
Andrew Hoban 6Andrew Hoban 6 

Test Class Successful, but 0% Code Coverage on Trigger

Hi,

I have a test class that we have been using for several months without any issues. Now however, when I run the test, it is passing the test, however the trigger remains on 0% code coverage. 

Is there something im missing?

Test Class
@isTest(SeeAllData=true)
public class AutomatedApprovalRequestMedia_Test{

public testmethod static void runTest(){  
 Purchase_Orders__c PO1 = new Purchase_Orders__c(
            Name = 'Test',
            Quantity__c = 4,            
            Price_Ex_VAT__c = 600.00,
            For_Department__c = 'Academy',
            Carriage__c = 400.00,
            Ordered_Date__c = Date.newInstance(2017 , 07 ,15),
            Approved__c = false,
            Ownerid = '005a000000BHKWs',
            recordTypeid = '012a0000001RWi2 );
        
         try
        {
            insert PO1;
                
            AutomatedApprovalRequest.submitApproval(po1.id);
        }
        catch(Exception ee)
      {
            
        }   
        
        }
        }

Trigger
trigger ApproveProcessAutomationMedia on Purchase_Orders__c (after insert, after update) {

 //Media
    if(ApproveProcessAutomationHandler.isFirstTime)
    {
        ApproveProcessAutomationHandler.isFirstTime =  false;
        Purchase_Orders__c PurchaseOrdersMedia = Trigger.new[0];
        //MEDIA
        if((PurchaseOrdersMedia.Ownerid == '005a000000BHKWs' || PurchaseOrdersMedia.Ownerid == '005a000000BGw6l') && PurchaseOrdersMedia.RecordTypeId == '012a0000001RWi2'  &&  PurchaseOrdersMedia.Total_Formula__c >= 250.00 && PurchaseOrdersMedia.Total_Formula__c <= 499.99 && PurchaseOrdersMedia.Approved__c == false)
        {
            //call approval method
            AutomatedApprovalRequest.submitApproval(PurchaseOrdersMedia.id);
        
        }
        //MEDIA
        Else if((PurchaseOrdersMedia.Ownerid == '005a000000BHKWs' || PurchaseOrdersMedia.Ownerid == '005a000000BGw6l') && PurchaseOrdersMedia.RecordTypeId == '012a0000001RWi2'  &&  PurchaseOrdersMedia.Total_Formula__c >= 500.00 && PurchaseOrdersMedia.Approved__c == false)
        {
            //call approval method
            AutomatedApprovalRequest.submitApproval(PurchaseOrdersMedia.id);
        
        }
        //MARKETING
        Else if((PurchaseOrdersMedia.Ownerid == '005a000000BrxOW' || PurchaseOrdersMedia.Ownerid == '005a000000BHKWs' || PurchaseOrdersMedia.Ownerid == '005a000000BryCM' || PurchaseOrdersMedia.Ownerid == '005a000000BrxOb' || PurchaseOrdersMedia.Ownerid == '00530000005jMHi' || PurchaseOrdersMedia.Ownerid == '005a000000BGw6l' || PurchaseOrdersMedia.Ownerid == '00530000004F3oe') && PurchaseOrdersMedia.RecordTypeId == '012a0000001RWi7' && PurchaseOrdersMedia.Total_Formula__c >= 500.00 && PurchaseOrdersMedia.Approved__c == false)
        {
            //call approval method
            AutomatedApprovalRequest.submitApproval(PurchaseOrdersMedia.id);
        
        }
        //PARTNERSHIPS
        Else if(( PurchaseOrdersMedia.Ownerid == '005a000000BGw6l' || PurchaseOrdersMedia.Ownerid == '00530000004F3oe' ) && PurchaseOrdersMedia.RecordTypeId == '012a0000001RX2D' && PurchaseOrdersMedia.Total_Formula__c >= 500.00 && PurchaseOrdersMedia.Approved__c == false)
        {
            //call approval method
            AutomatedApprovalRequest.submitApproval(PurchaseOrdersMedia.id);
        
        }
        
    }   
 
}

 
RaidanRaidan
You might want to remove the try-catch block from the test method and see if there is an actual exception from the Trigger code.