+ Start a Discussion
Soundar Raj PonpandiSoundar Raj Ponpandi 

How to cover a test class for this simple class ?


How to cover a test class for followig apex class.
Apex Class

public without sharing class GD_RemoveProcessRecords {

    public static void removeProcess(List<Approval.ProcessWorkitemRequest> requests){
         Approval.process(requests, true);

Test Class
public class GD_RemoveProcessRecordsTest {
    static testMethod void removeProcessTestMethod() {
        Account acc1 = GD_TestDataFactory.createCustomer('Acc1','Customer');
        acc1.GD_Pharma_Location__c = 'Dubai';
        acc1.GD_Pharma_Account__c = true;
        Insert acc1;

        GD_Order__c ord = new GD_Order__c(GD_Account__c = acc1.id);
        insert ord;
        Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
        req.setComments('Submitting request for approval.');
        req.setNextApproverIds(new Id[] {UserInfo.getUserId()});
        Approval.ProcessResult result =  Approval.process(req);
        //GD_RemoveProcessRecords.removeProcess(new List<Approval.ProcessWorkitemRequest>{req});

Thanks in advance,
ANUTEJANUTEJ (Salesforce Developers) 
Hi Soundar,

In the test method, I think you will have to call the method that you will have to call the method with appropriate values that are necessary for the method to run.

I hope this helps and in case if this is useful can you please choose this as the best answer so that it can be used by others in the future.