+ Start a Discussion
AmbigaRamAmbigaRam 

Test code for email inbound handler..

Hi,

 

Can anybody help me to write the test coding for the following email inbound handler?

 

global class CaseEmailInBoundHandler implements Messaging.InboundEmailHandler {

    global Messaging.InboundEmailResult handleInboundEmail(
       Messaging.InboundEmail email,
       Messaging.InboundEnvelope envelope) {

 CaseEmailInBoundUtilities handler = new CaseEmailInBoundUtilities();
        Messaging.InboundEmailResult result = handler.processInboundEmail(email);
        return result;        
    }
}

 Thanks and Regards.,

Ambiga

levaleva

Something like this maybe 

 

@isTest
private class CaseEmailInBoundHandlerTest {

	static testMethod void testCaseEmailHandler () {
    	//set up     	    	
    	Messaging.InboundEmail email = new Messaging.InboundEmail();
        email.Subject = '______________________';
        email.plainTextBody = null;
        Messaging.InboundEnvelope envelope = new Messaging.InboundEnvelope();
        CaseEmailInBoundHandler mailer = new CaseEmailInBoundHandler(); 
            	
    	//run test
    	Test.startTest();
    	    mailer.handleInboundEmail(email, envelope);
        Test.stopTest();
    }    
}

 

 

AmbigaRamAmbigaRam

Thanks a lot Leva,

 

It works and coverage is 100 %.

 

 

Regards.,

Ambiga