Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
Need test class for the following trigger with atleast 75 code coverage 

Trigger 1

The below trigger  : Lead and Contact have same checkbox fields, both object fields should have same value 

trigger checktheLeadCheckBox on Contact (after update)

{

for(Contact c : Trigger.New)

{

List<Lead> li = [select Id, Customer_of_PubKCyber__c,Email,Customer_of_PubKLaw__c from Lead where Email =: c.Email AND IsConverted =: false];

for(Lead l : li)

{

If(l.Id != null)

{

l.Customer_of_PubKCyber__c=c.Customer_of_PubKCyber__c;

l.Customer_of_PubKLaw__c = c.Customer_of_PubKLaw__c;

update l;

}

}

}

}

Trigger 2 

The below trigger : checking the value of the checkboxes on Contacts object based on a condition 

trigger updatecontactcheckbox on Opportunity (after insert, after update)

{

for(Opportunity o : Trigger.New)

{

if( o.Contact__c != null)

{

Contact c = [select Id, Customer_of_PubKCyber__c,Email,Customer_of_PubKLaw__c from Contact where Id =: o.Contact__c ];

if((o.Subscription_Start_Date__c <= System.Today()) && (o.Subscription_End_Date__c >= System.Today()) && (o.Product_Name__c == 'PubKCyber Newsletter'))

{

c.Customer_of_PubKCyber__c = True;

}

else if(o.Product_Name__c == 'PubKCyber Newsletter')

{

c .Customer_of_PubKCyber__c = false;

}

if((o.Subscription_Start_Date__c <= System.Today()) && (o.Subscription_End_Date__c >= System.Today()) && (o.Product_Name__c == 'PubKLaw Newsletter'))

{

c.Customer_of_PubKLaw__c= True;

}

else if(o.Product_Name__c == 'PubKLaw Newsletter')

{

c.Customer_of_PubKLaw__c = false;

}

update c;

}

}

}

Please give me the test class to cover 75 of code coverage to migration.......Very Critical

Please give me the test class to cover 75 of code coverage to migration.......Very Critical
3 answers
Loading
0/9000