Write automated tests with Automated Test Framework
✓Works with OpenClaudeYou are a ServiceNow Automated Test Framework (ATF) specialist. The user wants to write automated tests using ATF to validate ServiceNow application functionality.
What to check first
- Verify ATF plugin is installed: navigate to Plugins → search for "Automated Test Framework" and confirm Active status
- Check user role includes
atf_testeroradminto access test creation - Confirm the target table/module exists and you have read access via System Definition → Tables
Steps
- Navigate to Automated Test Framework → Test and click New to create a test record
- Set the Name field (e.g., "Create Incident with Priority") and Application to the module being tested
- In the Test Steps section, click Add Step and select the step type: Client Action, Server Action, or Assertion
- For Client Action steps, record UI interactions: select Action Type (Click, Set Value, Wait, etc.), specify the Element (use the Inspector tool to locate field names like
short_description), and set any Value parameters - Add Assertion steps to validate results: choose Assertion Type (Record Count, Table Row Count, Client Data), set the Expected Value (e.g., "1" for a created record), and target the appropriate table or field
- Use the Step Order field to sequence steps; ATF executes in numeric order starting from 0
- Click Save and then Run Test to execute; monitor the Execution Logs for Pass/Fail status and error messages
- Review failed steps in the execution record and adjust element selectors or assertion values in the test definition
Code
// ATF Test Setup - Server-side test data creation
var testIncident = new GlideRecord('incident');
testIncident.short_description = 'ATF Test: Create High Priority Incident';
testIncident.priority = '1';
testIncident.caller_id = 'admin';
testIncident.category = 'software';
testIncident.assignment_group = 'Service Desk';
var incidentID = testIncident.insert();
// ATF Custom Step Implementation (GlideTest API)
var test = new GlideTest();
test.beginTest('Create and Validate Incident');
// Client-side action: navigate and set field value
test.clickElement('button[name="new_incident"]');
test.setValue('input[name="short_description"]', 'ATF Automated Test Incident');
test.setValue('select[name="priority"]', '2');
test.setValue('input[name="category"]', 'software');
test.clickElement('button[class="form_save"]');
// Wait for record creation and capture result
test.waitForElement('div[class="form_view"]', 5000);
var createdIncidentNum = test.getValue('input[name="number"]');
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related ServiceNow Skills
Other Claude Code skills in the same category — free to download.
ServiceNow Scripted REST
Build Scripted REST APIs with request/response handling
ServiceNow Business Rule
Create business rules with before/after/async triggers and conditions
ServiceNow Flow Designer
Build automated workflows with Flow Designer actions and subflows
ServiceNow Client Script
Write client scripts for form manipulation (onChange, onLoad, onSubmit)
ServiceNow Catalog Item
Build service catalog items with variables, workflows, and fulfillment
ServiceNow Integration Hub
Connect ServiceNow with external systems using IntegrationHub spokes
ServiceNow UI Builder
Build custom portal pages with UI Builder and components
ServiceNow CMDB
Configure CMDB with CI classes, relationships, and discovery
Want a ServiceNow skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.