+ 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.
private class EmailCaseDLTest {    
    Static testMethod void Test_EmailCaseDL(){                
        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;        
        // update Internal status and sub-status
        c.Internal_Status__c = 'Open';
        c.Sub_Status__c      = 'Awaiting Information';                
        UPDATE c;


ShirishaShirisha (Salesforce Developers) 
Hi Ankit,


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.


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

Thank you!

Shirisha Pathuri