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
Saru VadlamudiSaru Vadlamudi 

How to test Time dependent workflow

i have the scenario that workflow has to trigger before 180 days of end date.
When i testing with providing all the criteria satisfied even then email in not triggering.
Please suggest me how to test it.
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,

There is a way to test time based workflow.  Trigger the workflow, then go to Setup|Monitoring|Time Based Workflow and see that the action has been queued (you can also see what time it's queued for).  If anything happens between when you triggered the action and when it's actually supposed to happen that violates the workflow criteria then the action(s) will be unqueued.

Hope this helps

--
Regards,
Swayam
@Salesforceguy
Amit Shirude 35Amit Shirude 35
@Swayam,

Have you tried it in a Test Class? Need to confirm if the Future event will be fired successfully. 
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi Amit,

Whenever you want to run the unit tests it is meant for code, as time-based workflow is related to configuration part it doesn't run in unit testing.

Please find the below which can successfully run in unit testing.
Batch Apex
Schedule Apex
Queueable apex
Future Methods etc.

Hope this helps

--
Regards,
Swayam
@Salesforceguy
 
Amit Shirude 35Amit Shirude 35
Thank you Swayam.

My intention is to test scenarios in the application. I will assert on the Count of flowInterview object for the time being.

Cheers!