You need to sign in to do that
Don't have an account?
Ghanesan
Method does not exist or incorrect signature: void sendEmail(Id, Id) from the type LeadEmailBounce
Getting this error on test class " Method does not exist or incorrect signature: void sendEmail(Id, Id) from the type LeadEmailBounce"
Here is my Apex Code:
public class LeadEmailBounce {
@InvocableMethod
public static void Bounce(){
List<Lead> L1 = [SELECT EmailBouncedDate,EmailBouncedReason,Id,Name FROM Lead];
List<Lead> L2 = new List<Lead>();
for(Lead Leads:L1) {
If (Leads.EmailBouncedDate!=Null && Leads.EmailBouncedReason!=Null)
{
Leads.Status = 'Disqualified';
Leads.Reason_for__c = 'Inadequate Data';
L2.add(Leads);
}
update L2;
}
}
}
Test Class:
@istest
public class LeadEmailBounceTest {
Public Static testmethod void BounceTest() {
Lead L1 = new Lead();
L1.lastname ='Test';
L1.Email ='thara@gail.com';
insert L1;
Lead L2 = new Lead();
L2.lastname='Test2';
L2.Email ='thar@gail.com';
insert L2;
LeadEmailBounce.sendEmail(L1.id, L2.id);
}
}
Here is my Apex Code:
public class LeadEmailBounce {
@InvocableMethod
public static void Bounce(){
List<Lead> L1 = [SELECT EmailBouncedDate,EmailBouncedReason,Id,Name FROM Lead];
List<Lead> L2 = new List<Lead>();
for(Lead Leads:L1) {
If (Leads.EmailBouncedDate!=Null && Leads.EmailBouncedReason!=Null)
{
Leads.Status = 'Disqualified';
Leads.Reason_for__c = 'Inadequate Data';
L2.add(Leads);
}
update L2;
}
}
}
Test Class:
@istest
public class LeadEmailBounceTest {
Public Static testmethod void BounceTest() {
Lead L1 = new Lead();
L1.lastname ='Test';
L1.Email ='thara@gail.com';
insert L1;
Lead L2 = new Lead();
L2.lastname='Test2';
L2.Email ='thar@gail.com';
insert L2;
LeadEmailBounce.sendEmail(L1.id, L2.id);
}
}
There is no method in your class LeadEmailBounce with the name sendEmail() and so you are seeing this error at below line in test class
LeadEmailBounce.sendEmail(L1.id, L2.id);
Replace above line with
See below link that has code sample for unit test
https://salesforce.stackexchange.com/questions/274601/unit-tests-on-bounced-email
If this information helps, please mark the answer as best. Thank you