function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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