Question: My goal is to configure a trigger on the CampaignMember object in SF that, when fired, will send a marketing cloud email. We are using a Web2Lead form that will pass the campaign value into SF, which should be used to trigger the email to the person that submitted the form.

In configuring the object for triggers in SF, I used this code from the marketing cloud documentation (replacing Object Name with CampaignMember):

```
trigger Trig_Object Name on Object Name (after insert, after update) {
    et4ae5.triggerUtility.automate('Object Name');
}

```

Now I need to create the test class. This is the code someone sent me, but I think I have the required fields and values incorrect because I'm getting an error (I replaced 'field1 = 'test1" with 'Campaign=Event\_1' and deleted field2 and 3):

```
@isTest(Seealldata = true)                                    
public class Trig_CampaignMemberTest {  
    static testmethod void InsertCampaignMember() {

    CampaignMember cmp = new CampaignMember('field1' = 'test1', 'field2' = 'test2','field3' = 'test3');
    Insert cmp;

    }
}

```

I received this error: 
Compile Error: SObject constructor must use name=value pairs at line 5 column 22

Am I missing something? Any feedback is highly appreciated. I'm new to this!

Answer: 
When writing a test class, one way to think about it is to build code that does the same thing a User will do in Salesforce themselves.

In the case of a Campaign Member, the typical User process is something like this:

1. Create an Account
2. Create a Contact on that Account
3. Create a Campaign
4. Create a CampaignMember to add the Contact to the Campaign.

Likewise, in your Apex test code, you need to do all of these things. A CampaignMember is a detail object to Contact and Campaign, so you can't insert one without those other things already being there. Here is the bare minimum you would need to do all of these things:

```
static testmethod void sampleTest()
{
    Account a = new Account(Name = 'Account');
    insert a;

    Contact c = new Contact(AccountId = a.Id, LastName = 'Contact');
    insert c;

    Campaign camp = new Campaign(Name = 'test campaign');
    insert camp;

    test.startTest();

    CampaignMember testCM = new CampaignMember(CampaignId = camp.Id,                 
            ContactId = c.Id);
    insert testCM;

    test.stopTest();
}

```

This is not commented, and does not do any actual testing at all, since it doesn't make sure the code performs properly. I suggest you not just copy this into your class, but spend some time understanding how it works. Writing test code is integral to Apex programming.
To answer your question, the syntax is fieldname without quotes, literal value in quotes:

```
CampaignMember cmp = new CampaignMember(Campaign = 'test1');

```

Also as an aside, I would advise against using seealldata=true in your test class. You're starting on the correct approach by creating test data within your test, so there shouldn't be any need for you to use seealldata.