Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Async updates via Automated Test Framework - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Async updates via Automated Test Framework
KB0787886

Async updates via Automated Test Framework


443 Views Last updated : Oct 10, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

Async activities like workflow,  BR's etc triggered by an automated test may not complete within the time frame of the test execution. 

So any step that assert on the result of these async activities may result in the automated test failure.

Cause

The async activities run independently of the automated test and is not bound to complete within the test execution time frame.

 

For example: In the example below the 'Record Query' step failed as the workflow activity that was meant to create a record ran few milliseconds after the test step :


2019-12-01 15:45:57 (078) worker.7 worker.7 txid=3ece7c1813e1 Processing step order: 19 for step config: Record Query

2019-12-01 15:45:57 (095) worker.7 worker.7 txid=3ece7c1813e1 SessionDebug 'log' enabled for user: <user>

2019-12-01 15:45:57 (552) worker.6 worker.6 txid=15ee305813e1 DEBUG: completed <worflow activity name>(5db7a88c133f3300a42330128144b050): event=execute

Resolution

We do not encourage the use of gs.sleep in ATF, because:

  1. If you're not waiting for a specific condition that means you're wasting time if e.g. the condition is true after just 1 second.
  2.  gs.sleep() does not work in scoped applications.

The recommended pattern, if waiting for a record condition, is to use either "Record Query" or "Record Validation" with a timeout (wait until a specific record exists or until the record reaches a specific state).

If you only have to perform something that requires scripting, you should instead use sn_atf.AutomatedTestingFramework.waitOneSecond(), which both:

  1. Does not let you wait more than one second and therefore forces you to break out as soon as your condition is true.
  2. Works in scoped applications.

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.