OBLYTECH Logo
OBLYTECH Logo
ServiceNow Automated Test Framework Best Practices

ServiceNow Automated Test Framework Best Practices

The Automated Test Framework is the ServiceNow tool for building repeatable checks on configuration and workflows, and its best practices decide whether those checks stay useful. This page sets out how to build, organize and maintain those checks, and what to do when one goes red.

Use Test-Driven Development to Validate Platform Changes Before Production

Testing platform changes after they are deployed to production is slow and risky. Instead, write tests before deploying configuration changes so you verify the change works before releasing it. ServiceNow’s Automated Test Framework (ATF) allows you to write tests in the browser or through APIs: navigate a form, enter values, verify expected results. Build tests for critical functionality: does a business rule execute correctly, does a workflow route records to the right queue, does a report show the right data? When you change configuration, run existing tests to verify you did not break anything. For major platform changes, build a test suite and run it before promotion to staging and production. This test-first approach catches configuration errors while they are still easy to fix.

Organize Tests Into Logical Groups With Clear Naming and Descriptions

An untested ATF script is useless, but a project with hundreds of tests with names like test_1, test_2, and test_workflow is also useless because you cannot find the test you need or understand what it validates. Organize tests into suites by module or feature: tests for incident workflow in one suite, tests for change management in another. Name tests clearly: test_critical_incident_goes_to_tier_1, test_change_requires_approvers_if_high_risk. Add descriptions to each test explaining what it validates and what the expected outcome is. When a test fails, the description should help you understand what went wrong. Group related tests into test suites so you can run the full suite for a module with one command.

Use Data Fixtures to Initialize Test Data Consistently

Tests that depend on specific test data are brittle: if someone deletes the test data, tests fail even though your platform is working correctly. Use ATF’s data setup capabilities to create test records before each test runs: create an incident record with specific values, create a user with specific roles, create a group. This approach ensures each test is independent and can run in any order. Define fixtures that represent realistic scenarios: a critical incident assigned to tier 1, a routine change request assigned to standard queue. Reuse fixtures across multiple tests to save effort and ensure consistency. Clean up test data after tests run so tests do not clutter your test instance.

Implement Assertions to Validate Outcomes at Multiple Steps

A test that just navigates through a workflow without checking intermediate results is weak. At each step in your test, assert expected values: after submitting an incident, verify the ticket number was created, verify it is assigned to the correct queue, verify a notification was sent. If an intermediate step fails, the test should fail immediately with a clear message rather than continuing and failing at a later step. Use assertions to validate not just record values but also UI state: verify that a button is enabled or disabled, verify that a list contains expected items. ATF provides assertion methods for comparing values, checking for empty or null values, and validating data types.

Execute Tests Regularly and Track Failures in a Defect Management Workflow

Tests are valuable only if they run regularly: before production deployments, after plugin updates, daily if your platform is under active development. Use scheduled jobs to run test suites automatically on a schedule (nightly or weekly), and use webhooks to trigger tests when code changes are merged. When tests fail, create a defect record in your issue tracking system with the test failure details so someone can investigate and fix either the test or the configuration. Do not ignore test failures; each failure indicates either a real platform problem or a test that is poorly written and needs fixing. Track test failure trends: if a particular feature has frequent failures, it needs attention. Maintain a high bar for test reliability: a flaky test that sometimes passes and sometimes fails is worse than no test.

Document Test Scenarios and Maintain Test Case Library

A test that validates incident escalation should document when the escalation rule applies (incident is critical priority, assigned to tier 1), what actions should happen (escalation notification sent, on-call engineer contacted), and what conditions might prevent escalation. This documentation helps future developers understand the test’s purpose and modify it when business rules change. Maintain a library of common test scenarios: creating records, testing approvals, testing notifications, testing reporting. Reuse test scenarios across projects rather than writing new tests from scratch. When you find a bug, create a test that reproduces the bug, fix the bug, and verify the test passes. This ensures the bug does not regress in future updates.

Practices that keep a suite trustworthy after its first year

Suites rarely fail on the day they are written. They fail later, once the original authors have left, the test data has drifted, and a red result has been ignored so many times that nobody reads the log. The practices that matter most are the ones that keep a failing test meaningful: tests that explain what they protect, data that is controlled, and a clear rule for what happens when a test goes red. Each of these is cheap at the start and very expensive to retrofit.

Standards every test should meet before it is merged

Standard What it looks like in practice What breaks when it is missing
Named purpose A description that states the workflow and the failure it guards against Nobody can tell whether a failing test still matters after a redesign
Controlled data Records created by the test with unique identifiers and removed afterwards Runs interfere with each other and fail for no platform reason
Assertions at each step Checks after every significant change, not only at the end A failure is reported far from the step that caused it
Role-specific execution Each test runs under the role it is meant to test An administrator account hides access regressions
Owner recorded A named team responsible for the workflow the test protects Failures are disabled rather than investigated

A review routine for the existing suite

  1. Export the list of tests with their descriptions, owners and last run results, and mark any test missing a purpose or an owner.
  2. Check each test for hard-coded records, usernames or dates, and replace them with values the test creates.
  3. Re-run the suite three times in a clean environment and flag any test whose result changes between runs.
  4. Match each test to the workflow it protects, and retire tests whose workflow no longer exists.
  5. Where two tests check the same behavior at different depths, keep the cheaper one and document the choice.
  6. Record the findings and the changes in the suite’s change log, so a later reviewer can reconstruct the reasoning.

Handling a red result without losing the team’s trust

A failing test should trigger a short, defined response, not a discussion about whether the test is worth having. The first step is to decide whether the failure is in the platform, in the test or in the environment. A test defect is fixed in the suite. A platform defect goes to the team that owns the change, with the failing step and the record state attached. An environment defect goes to the team that runs the environment. Keeping those three routes separate stops failures drifting between teams for days.

Where a test is genuinely wrong and cannot be fixed quickly, disable it openly with a note and a date for review. Silent disabling is one of the quickest ways to destroy confidence in the suite.

How to tell the practices are holding

Good practice shows as stable results across repeated runs, short investigations and few tests with no owner. It also shows when a platform change is accompanied by test changes in the same release, which keeps the suite aligned with what the platform now does. If the suite is green but users keep finding the same kinds of fault, the tests are checking the wrong things. That is a question for the workflow owner as much as for the test author.

The testing and acceptance checklist describes how suite results feed into the release decision, and the common mistakes guide covers patterns that often undermine these standards.

Where the practices need adjusting for a small team

A small team may not have a separate maintainer for the suite, and the practices can then feel out of reach. The workable compromise is to keep the standards for new tests strict and apply the review routine to one workflow at a time. Trying to clean up the whole suite in one pass often stalls, while a steady rhythm of small reviews keeps the suite useful. Splitting upkeep between people who also hold other duties is worth settling early, and the roles and responsibilities guide lists who does what.

Should every test use the same naming pattern?

A consistent pattern helps, but a description that says what the test protects matters more than the name. Choose one convention, document it, and apply it to new tests first.

How often should the review routine run?

Often enough that no test goes unexamined for long. Set the review cadence from the release calendar, since it should follow how often the platform changes rather than a fixed interval.

Is it acceptable to keep a test that only runs manually?

Yes, if it is clearly marked and its manual run is recorded. A documented manual test is more useful than an automated one that nobody runs.

What is the first sign that practices have slipped?

Tests with no owner, or red results that have been red for several cycles without an investigation note. Either one means the response routine is no longer being followed.

ServiceNow Automated Test Framework regression testing after an upgrade

After a ServiceNow upgrade, run a prioritized regression pack in the Automated Test Framework on a sub-production instance cloned from production: smoke checks first, then critical workflows, access rules and integrations, then the rest. Fix or explain every failure before promotion, and update tests the upgrade changed on purpose.

Order matters because a full suite can take a long time, and the first results should tell you whether the upgrade is sound enough to keep testing.

Pack What it covers When it runs
Smoke Sign in, open the main forms, create one record in each core module Straight after the upgrade completes
Critical workflows Routing, approvals, SLA timers and the notifications that people act on Once the smoke pack is green
Access Role-restricted actions, run as users holding only that role After the workflow pack
Integrations Inbound and outbound calls, using stubs where a target is unavailable After the access pack
Everything else The remaining suites Overnight

Sort each failure into a group before assigning it. Typical groups are user interface steps that no longer match a changed form, features the upgrade replaced, customizations that clash with new baseline behavior, and data or integration differences on the cloned instance. The grouping shows quickly whether you are facing a test problem or a platform problem.

An upgrade can change behavior deliberately. When a test fails because the baseline now acts differently, change the test and record the reason in the same piece of upgrade work. Do not disable it and move on. The upgrades and release readiness guides show where this fits in the wider plan, and platform performance and upgrade readiness describes the service built around it.

What is the Automated Test Framework in ServiceNow?

It is the built-in ServiceNow tool for building and running automated tests of configuration, workflows and user interface steps without external scripts. Tests are ordered steps grouped into suites and run on the instance, which suits repeatable checks around changes and upgrades.

How many tests are enough for an upgrade?

There is no useful fixed number. Cover each workflow whose failure would stop work or cause a compliance problem, plus the access rules around it. A smaller pack that people trust and run every time beats a large one that gets skipped.

Should regression tests run on production?

Run them on a sub-production instance holding a recent copy of production configuration and data. That keeps real records safe and lets a failure block promotion before any user is affected.

Frequently asked questions

How do we handle tests that depend on timing, like waiting for a scheduled job to run?

Avoid time-dependent tests when possible. Use mocking or test modes that simulate job execution without waiting. If a test must wait for asynchronous behavior, set a timeout that is longer than typical execution but fails if the job takes too long, indicating a performance problem.

Should we test every possible scenario or focus on critical paths?

Start with critical paths and high-risk changes. A complete test suite covering every scenario is ideal but often not practical. Focus on testing functionality that, if broken, would significantly impact business operations.

How do we handle test failures in external systems that our code depends on?

Mock external systems in tests so test failures are due to your code, not external systems. Use a test sandbox for external systems if available. Document dependencies and known failures so your team understands why a test failed.

Talk to Oblytech

Planning, running or fixing a ServiceNow programme? Tell us where you are and we will suggest a sensible next step.

Contact us