+ Start a Discussion
Kevin Chiles 930Kevin Chiles 930 

Not enough coverage of code to deploy

Hello!

I have a trigger that is updating a record type to a child object.  I have a test class built but it is only covering 66 percent of the trigger, can anyone help me to get this coverage up?  Trigger and class below
trigger PartnerContractRecordtype on Case (before update) {

for (Case c : Trigger.New) {
 
Partner_Contract__c pc =[Select Id ,RecordTypeId from Partner_Contract__c where id=:c.Partner_Contract__c limit 1];
//this line is not covered in the class 
RecordType rt = [select id from Recordtype where SobjectType='Partner_Contract__c' and Name =:'Approval'];

if (c.Status =='Partner - Pending Paperwork' && c.Partner_Contract__c!=Null){



pc.RecordtypeId=rt.id;

update pc;
}
}
}
 
@isTest(SeeAllData = true)
public class PartnerContractTrigger
{
    public static testMethod void PartnerContractTrigger()
    {
    
    Account a = New Account(Name='test',recordtypeId=[Select Name, Id From RecordType
        Where sObjectType='Account' and isActive=true and Name='Affiliate'].id);
        
        insert a;
        
        Contact ct=New Contact(FirstName='sarah',LastName='jenny',email='test@test.com',AccountId=a.id);
    insert ct;
        
        Account mpdefault = New Account(Name='Megapath - Default',recordtypeId=[Select Name, Id From RecordType
        Where sObjectType='Account' and isActive=true and Name='Affiliate'].id);
        
        Contact ct2=New Contact(FirstName='sarah',LastName='jenny',email='test@test.com',AccountId=mpdefault.id);
        insert ct2;
        
        Insert mpdefault;
        
        Partner_Contract__c pc = New Partner_Contract__c(Name='0',Parent_Partner__c=mpdefault.id,Status__c='Active',
        PartnerProgram__c='Referral',Partner__c=a.Id,recordtypeId=[Select Name, Id From RecordType
        Where sObjectType='Partner_Contract__c' and isActive=true and Name='Non Approval'].id
        );
        Insert pc; 
        
        Availiable_Contract__c ac = New Availiable_Contract__c(Name='0',Contract_Rank__c=1,Partner__c=a.Id,Partner_Contract__c=pc.Id 
        );
                   
        Insert ac;       
        
        RecordType recordtypeId2=[Select Name, Id From RecordType
        Where sObjectType='Partner_Contract__c' and isActive=true and Name='Approval'];
        
        Case C= new Case(AccountId=a.id,ContactId=ct.Id,Sales_Rep__c=UserInfo.getUserId(),Case_Request_Type__c='Partner Onboarding',
        recordtypeId=[Select Name, Id From RecordType
        Where sObjectType='Case' and isActive=true and Name='Channel Support'].id,Partner_Contract__c=pc.id,Company_Name__c=a.Name,
        Clarity_Account_ID__c='N/A',Site_Contact__c='Test', Site_Contact_Phone__c='3157775695',Primary_Affiliate__c='Megapath - Default',
        Primary_Affiliate_ID_2__c='1980',Subject='Onboarding Request for New Partner',Description='Onboarding Request for New Partner');
        
        insert c;
                     
        c.Status='Pending Partner Paperwork';
        update c;
        
        
          
        Pc.Name='1234';
        pc.Status__c='Active';
        Pc.Partner_Contract_Status__c='Partner Activated';
       // pc.recordtypeId=[Select Name, Id From RecordType
       // Where sObjectType='Partner_Contract__c' and isActive=true and Name='Approval'].id;
        update pc;  




    }
}