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
Ankit Kalsara 6Ankit Kalsara 6 

Test class for scheduled apex of process builder

Hi team,

I have created a test class for code coverage of my apex class which gets called 30days after the criteria are met. During the test run, I am getting 0% code coverage. 

My process builder criteria is: when the case moves to Open, I am calling scheduled action 30days from now and calling the apex class inside.
The apex class simply sends an email to case contact.

Below is my test class.
@isTest
private class EmailCaseDLTest {    
    
    Static testMethod void Test_EmailCaseDL(){                
               
        TestData.insertTemplateEntitlements();
        Account acct = TestData.createAccountWithAddress('Test Account Email Case DL', 'Boston', 'MA', '02115', 'US');
        INSERT acct;    
        
        // create the Contact under the Account
        Contact ct = new Contact(AccountId = acct.Id,
                                 lastName  = 'lastname',
                                 firstName = 'firstname',
                                 email     = 'testingContact@test.com');        
        INSERT ct;
       
        // Create the asset
        Asset ast = new Asset(Name = 'test Asset1', AccountId = acct.Id);
        INSERT ast;        
        
        // Test insert
        Case c = new Case(AccountId   = acct.Id, 
                          AssetId     = ast.Id,
                          ContactId   = ct.Id, 
                          Subject     = 'Test case Subject', 
                          Description = 'test case description');
        c.DL_Of_Customer_Case_Team__c = 'ankit.kalsara@test1.com;ankit.kalsara2@test2.com';
        INSERT c;        
        
        Test.startTest();
        
        // update Internal status and sub-status
        c.Internal_Status__c = 'Open';
        c.Sub_Status__c      = 'Awaiting Information';                
        UPDATE c;
        Test.stopTest();        
    }

}

 
ShirishaShirisha (Salesforce Developers) 
Hi Ankit,

Greetings!

What is the issue that you are facing here.Have you tried to run the test class to see,if you are getting any error on the test class.Please refer the below thread for the sample test class for the apex class which is being invoked.

https://salesforce.stackexchange.com/questions/227162/test-class-help-send-email-class

Please mark it as best answer if it helps you to fix the issue.

Thank you!

Regards,
Shirisha Pathuri