What is wrong with this test class?
I'm getting the error:
Error: Compile Error: Unexpected token '='. at line 7 column 19
This is at "email.subject = ..."
What is possibly wrong with this assignment? It's exactly as described in Salesforce coding guidelines.
@IsTest
public class NewRelicInboundEmailAlerts_Test {
Messaging.InboundEmail email = new Messaging.InboundEmail();
Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
email.subject = 'FW: Incident 20216330';
env.fromAddress = '[email protected]';
// add an Binary attachment
Messaging.InboundEmail.BinaryAttachment attachment = new Messaging.InboundEmail.BinaryAttachment();
attachment.body = blob.valueOf('test');
attachment.fileName = 'bd27b20b74e689b19eacd89ed7a2a62decba7356.json';
attachment.mimeTypeSubType = 'application/json';
email.binaryAttachments = new Messaging.inboundEmail.BinaryAttachment[] { attachment };
// call the email service class and test it with the data in the testMethod
NewRelicInboundEmailAlerts testEmailAlert = new NewRelicInboundEmailAlerts();
testEmailAlert.handleInboundEmail(email, env);
}