You need to sign in to do that
Don't have an account?

test class compilation error
Hi, I am getting nullpointer exception while running below test class.
After inserting both contact and campaign objects only, i am referring them in campaign member object, wondering what i am missing here.
Below is the error
Class CampaignMemberTaskcreation
Method Name testtask
Pass/Fail Fail
Error Message System.NullPointerException: Attempt to de-reference a null object
Stack Trace Class.CampaignMemberTaskcreation.testtask: line 22, column 1
After inserting both contact and campaign objects only, i am referring them in campaign member object, wondering what i am missing here.
@isTest public class CampaignMemberTaskcreation { Static testmethod void testtask(){ Contact co1 = new Contact( LastName = 'Last', Title='CEO'); insert co1; string co1Id = co1.id; Campaign ca1 = new Campaign( Name = 'Testcampaign', Date_Sent__c=Date.today(), IsActive = TRUE); insert ( ca1 ); string ca1Id = ca1.id; CampaignMember m1 = new CampaignMember(); m1.Contact.Id = co1.Id; m1.Campaign.Id = ca1.Id; m1.status='Responded'; insert m1; } }
Below is the error
Class CampaignMemberTaskcreation
Method Name testtask
Pass/Fail Fail
Error Message System.NullPointerException: Attempt to de-reference a null object
Stack Trace Class.CampaignMemberTaskcreation.testtask: line 22, column 1
creation of campaignMember: