1

I am writing a test for a scheduled bach job that queries Process Instance to grab user info and targetobject info for tasks that are still pending. My query specifies elapsedTimeInDays greater than 5.

In my test class I had to dynamically submit an approval process but since my original query only grabs pending tasks that are older than 5 days I need to make sure I account for that in my test. Is there a method or way for me to assign the submitted date for my approval process that I am kicking off in my test class?

thank you

0

You can put a mock like this which will help to test those approval process

if(Test.isRunningTest())
{
    //query for elapsedTimeInDays = 0
}
else
{
   //query for elapsedTimeInDays >5 
}

Otherwise, look for a option to use Test.setCreatedDate(recordId, datetime) where you can assign any previous date, but I am not sure it is applicable for ProcessSubmitRequest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.