You need to sign in to do that
Don't have an account?
Tony Montana
I have created the following class
public class BEO_Send_Compliance_Survey_Class {
@InvocableMethod
public static void createParticipantRecord(List<Id> varRequestId)
{
Id SurveyRecipientRecordTypeId = Schema.SObjectType.Participant__c.getRecordTypeInfosByName().get('Survey Recipient').getRecordTypeId();
Map<Id, Participant__c> createParticipants = new Map<Id, Participant__c>();
List<Contact> theContacts =[select id, name from contact where NT_Login_Name__c != null and Former_Employee__c = false and Management_Level_Type__c in ('VP','Director')];
//FOR loop to run through Contact records in theContacts
for(Contact c : theContacts){
createParticipants.put(c.Id, new Participant__c(Participant__c = c.Id, Request__c = varRequestId[0],RecordTypeId=SurveyRecipientRecordTypeId));
}
//Insert the values (individuals) in the createTheseIndividuals map
insert createParticipants.values();
system.debug('hi i m here');
}
}
What should be the corresponding class with at least 80% coverage. ?
Thanks,
TM
@InvocableMethod
public static void createParticipantRecord(List<Id> varRequestId)
{
Id SurveyRecipientRecordTypeId = Schema.SObjectType.Participant__c.getRecordTypeInfosByName().get('Survey Recipient').getRecordTypeId();
Map<Id, Participant__c> createParticipants = new Map<Id, Participant__c>();
List<Contact> theContacts =[select id, name from contact where NT_Login_Name__c != null and Former_Employee__c = false and Management_Level_Type__c in ('VP','Director')];
//FOR loop to run through Contact records in theContacts
for(Contact c : theContacts){
createParticipants.put(c.Id, new Participant__c(Participant__c = c.Id, Request__c = varRequestId[0],RecordTypeId=SurveyRecipientRecordTypeId));
}
//Insert the values (individuals) in the createTheseIndividuals map
insert createParticipants.values();
system.debug('hi i m here');
}
}
What should be the corresponding class with at least 80% coverage. ?
Thanks,
TM
Please use below code
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
All Answers
Please use below code
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Please try below code:-
@isTest
private class TestBEO_Send_Compliance_Survey_Class {
private static void testCreateParticipantRecord() {
Lead lead1 = new Lead();
lead1.LastName = 'Test Lead',
lead1.Company = 'Test Company',
lead1.IsRecruitmentLead__c = True);
insert lead1;
contact contact1 = new contact();
contact1.name = 'TestContact';
contact1.NT_Login_Name__c = 'test1';
contact1.Former_Employee__c = false;
contact1.Management_Level_Type__c = 'VP Director';
insert contact1;
Test.startTest();
BEO_Send_Compliance_Survey_Class.createParticipantRecord(lead1.id);
Test.stopTest();
}
}
Please mark it as Best Answer if it helps you.
Thanks & Regards
Suraj Tripathi
coverage without asserts? not worth the effort of writing