-
Test Class for Inbound Email Service
I have written following inbound email service for lead object
global class LeadServices implements Messaging.InboundEmailHandler
{
global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)
{
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
string emailbody = email.plaintextbody;
string emailsubject = email.subject;
string subToCompare = emailsubject.Substring(emailsubject.indexof('ref :') + 5).trim();
try
{
lead l = [SELECT Id, Name,Email FROM lead WHERE id = : subToCompare];
Task newTask = new Task();newTask.Description = emailbody;
newTask.Priority = 'Normal';
newTask.Status = 'Inbound Email';
newTask.Subject = emailsubject;
newTask.IsReminderSet = true;
newTask.ReminderDateTime = System.now();
newTask.WhoId = l.Id;
Insert newTask;
}
catch(QueryException e)
{
System.debug('Issue: ' + e);
}
result.success = true;
return result;
}
}
I am have having 55% code coverage now.
Can someone please hepl me with test class for this?- This discussion was modified 4 years, 10 months ago by Prachi.
Log In to reply.
Popular Salesforce Blogs
Single or Multi-Org - What is your Salesforce Architecture?
While setting up a Salesforce Architecture or assessing the performance of an existing org, the most perplexing question that haunts anyone is to decide between…
Salesforce Health Cloud for Insurance: Optimize Operations
Insurance companies are constantly looking for ways to streamline their operations and provide better customer service. One solution that has gained significant traction in the…
Partnership of The Year – Salesforce Team Up With Apple!
Salesforce and Apple are two popular tech giants who have simplified technology and contributed big time to the tech world. Salesforce is known as the…
Popular Salesforce Videos
What is a Salesforce Architect?
If you are not familiar with the ‘Solution Architect’ role then it can be explained relatively simply. Solution Architects are ultimately responsible for the ‘Solution’…
Mocking Apex Tests: Salesforce Tutorial
In this Video Leonardo Berardino talks about the following: Mocking Apex Tests and Apex Mock Examples Unit Tests x Integration Tests How to create unit…
Introduction to Salesforce CTA Exam
The average salary for a Technical Architect is $118,324 per year in the United States. Do you also want to become Technical Exam by cracking…