Automated Test Framework and Run Script Workflow Activity Failure

MarkC2
Kilo Contributor

We have a workflow that, after start, immediately executes a Run Script workflow activity to set certain fields on the RITM for a Service Catalog item (e.g., setting the Short Description field). When I execute the test in the ATF, it fails when attempting validate that the Short Description equals the value it should be set to by the workflow. Instead, the Short Description is populated with the name of the Service Catalog item.

If I manually create a request for the Service Catalog item, after submission, the fields are set correctly. I've tested that numerous times manually, and it always works, but it fails in the Automated Test Framework. It's as if the workflow's Run Script activity doesn't execute at all. Has anyone encountered this issue? Or does anyone know of some suggestion on how to properly test this?

3 REPLIES 3

Bonnie Cresswe2
Kilo Guru

Hi

I went to a ServiceNow developer meetup the other night that did a deep-dive into ATF - the recommendation for anything where an async update is happening (such as if data is going to be updated by a workflow or an after business rule, event processing, etc) is to put a wait in between that and the validation step.  You can do that server-side by using gs.sleep(5000) - where the argument is in milliseconds, so 5000 will wait for 5 seconds

Hope that helps.

Regards

Bonnie

I tried this with a custom test step that allows us to specify a wait time. I waited 5 seconds, and it didn't make a difference. Oddly enough, when I skipped that test step and moved forward with the test, I had a step that updated the form and saved it. After the save, the Run Script activity in the workflow kicked off. Maybe I need to wait longer? I'll try that and update here.

 

EDIT: I tested this with a wait time of 5 seconds, then 10 seconds, then 30 seconds, and it does not execute the Run Script activity in the workflow.

Thanks for your suggestion, nonetheless.

Hi

Maybe I was confused with what your issue is - I read it as you have a run script activity that should be updating some data, and the validation of that record data is always failing in the ATF test...?   If that is the case the wait should be put AFTER the step where you are expecting the workflow run script activity to run, and before the validate record step, i.e. you give it time to let the workflow update the record before you validate that the data has been updated.  But also, is the record actually saved when that run script activity runs, or is there something else running after that to update/save the record?  You might be trying to validate the record too early in your test steps?

Regards

Bonnie