You need to sign in to do that
Don't have an account?
Becky Miller 15
Test Script Help
I have this Test Class code and I am not sure what I am doing wrong to get the 2 errors.
isTest
private class EmailServiceExampleTest
{
static testMethod void testUnsubscribe()
{
// Create a new email and envelope object.
Messaging.InboundEmail email = new Messaging.InboundEmail() ;
Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
// Create Test record.
Contact cont = new Contact(firstName='john', lastName='smith', Email='test@test.com', HasOptedOutOfEmail=false);
insert cont ;
// Test with the subject that matches the unsubscribe statement.
email.subject = 'Test Contact Email';
email.plainTextBody = 'Test Contact Email';
env.fromAddress = 'test@test.com';
EmailServiceExample obj= new EmailServiceExample();
obj.handleInboundEmail(email, env );
I am getting these 2 errors:
Line 20 - Invalid Type: EmailServiceExample
Line 21 - Variable does not exist: obj
isTest
private class EmailServiceExampleTest
{
static testMethod void testUnsubscribe()
{
// Create a new email and envelope object.
Messaging.InboundEmail email = new Messaging.InboundEmail() ;
Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
// Create Test record.
Contact cont = new Contact(firstName='john', lastName='smith', Email='test@test.com', HasOptedOutOfEmail=false);
insert cont ;
// Test with the subject that matches the unsubscribe statement.
email.subject = 'Test Contact Email';
email.plainTextBody = 'Test Contact Email';
env.fromAddress = 'test@test.com';
EmailServiceExample obj= new EmailServiceExample();
obj.handleInboundEmail(email, env );
I am getting these 2 errors:
Line 20 - Invalid Type: EmailServiceExample
Line 21 - Variable does not exist: obj
Now Line 21
Method does not exist or incorrect signature: void InboundEmail(Messaging.InboundEmail, Messaging.InboundEnvelope) from the type EmailServiceExampleTest
@isTest
private class EmailServiceExampleTest
{
static testMethod void testUnsubscribe()
{
// Create a new email and envelope object.
Messaging.InboundEmail email = new Messaging.InboundEmail() ;
Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
// Create Test record.
Contact cont = new Contact(firstName='john', lastName='smith', Email='test@test.com', HasOptedOutOfEmail=false);
insert cont ;
// Test with the subject that matches the unsubscribe statement.
email.subject = 'Test Contact Email';
email.plainTextBody = 'Test Contact Email';
env.fromAddress = 'test@test.com';
EmailServiceExampleTest obj= new EmailServiceExampleTest();
obj.InboundEmail(email, env );
}
}
All Answers
Now Line 21
Method does not exist or incorrect signature: void InboundEmail(Messaging.InboundEmail, Messaging.InboundEnvelope) from the type EmailServiceExampleTest
@isTest
private class EmailServiceExampleTest
{
static testMethod void testUnsubscribe()
{
// Create a new email and envelope object.
Messaging.InboundEmail email = new Messaging.InboundEmail() ;
Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
// Create Test record.
Contact cont = new Contact(firstName='john', lastName='smith', Email='test@test.com', HasOptedOutOfEmail=false);
insert cont ;
// Test with the subject that matches the unsubscribe statement.
email.subject = 'Test Contact Email';
email.plainTextBody = 'Test Contact Email';
env.fromAddress = 'test@test.com';
EmailServiceExampleTest obj= new EmailServiceExampleTest();
obj.InboundEmail(email, env );
}
}