You need to sign in to do that
Don't have an account?
Leonardo Girgenti 5
Help with a test class
Can anyone help me to write the Test Class for this Trigger?
I am not skilled to write it up so really need help. Thanks
trigger MeetingParticipantTrigger on Meeting_Participants__c(before insert){
Set<Id> contactIds = new Set<Id>();
for(Meeting_Participants__c mp : Trigger.new){
contactIds.add(mp.Contact__c);
}
Map<Id,Contact> contacts = new Map<Id,Contact>([Select AccountId From Contact Where Id in :contactIds]);
for(Meeting_Participants__c mp : Trigger.new){
Contact c = contacts.get(mp.Contact__c);
mp.Account2__c = c.AccountId;
}
}
I am not skilled to write it up so really need help. Thanks
trigger MeetingParticipantTrigger on Meeting_Participants__c(before insert){
Set<Id> contactIds = new Set<Id>();
for(Meeting_Participants__c mp : Trigger.new){
contactIds.add(mp.Contact__c);
}
Map<Id,Contact> contacts = new Map<Id,Contact>([Select AccountId From Contact Where Id in :contactIds]);
for(Meeting_Participants__c mp : Trigger.new){
Contact c = contacts.get(mp.Contact__c);
mp.Account2__c = c.AccountId;
}
}
Hey I am not sure which all are mandatory fields in your objects .
So here is the basic code of test class
@isTest
public class MeetingParticipantTrigger Test{
static testMethod void unitTest(){
//Create one account
Account acc= new Account();
acc.Name ="TestAccount";
Insert acc;
Contact con=new Contact();
con.lastName="Test";
con.AccountId=acc.Id;
Meeting_Participants__c metpt=new Meeting_Participants__c();
metpt.Contact__c=con.Id;
//Give all mandatory fields in your Meeting_Participants object
Insert metpt;
//Don't forget to add System.assert /assertEqual /assertNotEqual in each Dml atleast .
Let me know any issue .
}
}
I will try but I dont think I understand "
Don't forget to add System.assert /assertEqual /assertNotEqual in each Dml atleast".