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

test class for new trigger
Ive never really written a test class before so a little stuck trying to look at old ones to figure out what i need in order to test. Can anyone help. the class wont save saying the "Variable does not exist: tcontact.id"
@IsTest public class Lead_Campaign_Mid_Market_Test{ static testMethod void testCampMember() { // Create testing Camp, Lead, Contact and Campaign member data Campaign tCampaign = new Campaign(name='testcamp'); insert tCampaign; Lead tlead = new Lead(FirstName='SaraTester',LastName='testing',Lead_Routing_Override__c = 'Mid Market', Trigger_Assignment_Rules__c = true); insert tlead; Contact tcontact = new Contact(FirstName='JimTester',LastName='testing'); insert tcontact; CampaignMember tCampMemb = new CampaignMember(campaignId=tCampaign.id,leadId=tlead.id,contactId=tcontact.id,status='Responded'); insert tCampMemb; } }
In the above code that you gave there is a variable name tcontact.
It should not come there. Is this your whole code?
Make sure that you are not using that variable before it is declared.
From the above code it looks fine.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Yes the code shown is my entire test class.
I saved it in my org. It is saved without any error. The same code.
Thanks