Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to use Automated Testing Framework to test results of async Business Rules

bbarrowes
Tera Contributor

Hi, I am using Jasmine in ServiceNow to perform automated tests, using the Automated Testing Framework.  Everything is going great, but I don't know how to use the Automated Testing Framework to accomplish one type of test that I am wondering about.

 

I have an async Business Rule that fires when a certain field is changed, and in this chain of tests, I would like (1) make the change to a record that will allow the async Business Rule to fully execute, and (2) assert against the results of the async Business Rule having run.

 

I found the "Automated Test Framework Best Practices" document, which suggested that I take a "timeout" in order to wait for async code to be done running, but I tried adding a record-query step with a timeout in it--like in the picture on the document, and the execution of the Test Steps that come after the record-query-timeout step does not seem to be halted at all.  If adding a record-query step with a timeout is the correct way to do this, how can I correctly use this tool to be able to wait for asynchronous code to finish running?

 

If I were to use this record-query-timeout step approach, that would mean that in a simplified example, in Test Step 1, I would run the code that allows the asynchronous code to execute, Test Step 2 would be the timeout, and then Test Step 3 would be where I include the assertions against whatever the asynchronous code did.

 

Thanks in advance.

0 REPLIES 0