+ Start a Discussion
Leonardo Girgenti 5Leonardo 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){


    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;

Hi Leonardo ,

Hey I am not sure which all are mandatory fields in your objects .

So here is the basic code of test class 

public class MeetingParticipantTrigger Test{
   static testMethod void unitTest(){
      //Create one account 
        Account acc= new Account();
            acc.Name ="TestAccount";
            Insert acc;
       Contact con=new Contact();
       Meeting_Participants__c  metpt=new Meeting_Participants__c();
       //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 .

Leonardo Girgenti 5Leonardo Girgenti 5
I will try but I dont think I understand "
Don't forget to add System.assert /assertEqual /assertNotEqual in each Dml atleast".