@IsTest
private class EmailToSalesforceTests {
// Create a new email and envelope object
Messaging.InboundEmail email = new Messaging.InboundEmail();
Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
// Create the email body
email.plainTextBody = 'This should become a note';
email.fromAddress = '[email protected]';
String contactEmail = '[email protected]';
email.ccAddresses = new String[] {'Jon Smith <' + contactEmail + '>'};
email.subject = 'Dummy Account Name 123';
EmailToSalesforce edr = new EmailToSalesforce();
Test.startTest();
Messaging.InboundEmailResult result = edr.handleInboundEmail(email, env);
Test.stopTest();
System.assert (result.success, 'InboundEmailResult returned a failure message');
Account [] accDb = [select ID from Account where name=:email.subject];
System.assertEquals (1, accDb.size(),'Account was not inserted');
Contact [] cDb = [select firstname,lastname from Contact where email=:contactEmail];
System.assertEquals (1, cDb.size(),'Contact was not inserted!');
Contact c = CDb[0];
System.assertEquals ('Jon', c.firstName);
System.assertEquals ('Smith', c.LastName);
Note [] nDb = [select body from Note where ParentID=:accDb[0].id];
System.assertEquals (1,nDb.size(), 'A note should have been attached');
System.assertEquals (email.plainTextBody, nDb[0].body);
}
}
Hi All, above is my code, and I am receiving the Compile Error in the title. Any chance someone could assist me? I can't see anything wrong with the code, considering it was provided in the Salesforce documentation. Thanks.
static testMethod void theNameOfYourMethod() {
method and not defined directly in the scope of the class itself.