Automation is the name of the game for streamlining your organization’s processes, and adopting the ServiceNow platform is the first step to transforming your business.
So we have to ask - are you still condemning one of your employees to sit and perform tests manually, over and over, each time you’ve modified forms or upgraded your instance? Or are you the poor soul stuck with that task?
By setting up automated testing that you can reuse and modify, you take the error-prone human factor out of the loop. The Automated Test Framework (ATF) allows you to create and run automated tests on your ServiceNow instance to confirm that the instance still works as designed after being upgraded or modified. In this installment of our NOWSupport best practices series list, the following best practices will help you leverage the power of ATF.
But first, if you want to understand the basics of ATF, check out this video on our NowSupport YouTube channel:
And now, within the guiding principle of Always safeguard your production instance comes our first best practice:
Always run ATF, or any other testing framework, within a dev or test instance but never within prod
This best practice goes hand-in-hand with why you shouldn’t develop on your production instance. You may be tempted to run a quick test on your production instance to verify a minor change, but never succumb to that urge. Why? Here are a couple scenarios:
- A test can change data that may be designed to trigger actionable events, like sending out emails. You don’t want to have to explain to your manager why your test sent emails to your entire customer base, do you?
- A test can impersonate users with extensive security access. Even a minor oversight could allow test user Joe Admin to run amok.
Start a test with an Impersonate step to ensure the test user has the required roles
We recommend that you always configure an Impersonate step as the first step in your test. To do this, select Impersonate as the first test step, and specify the user to impersonate. In doing so, you can ensure that the test user has the required roles and behaves like that specific user.
Why bother to employ this step if you run the test as the test designer user? Because your test could break if someone changes the test designer user roles, or disables the test designer user. Or, you may find that the test can’t access a record or form properly based on the correct user roles. Setting up an impersonate step helps you avoid all these pitfalls.
Be aware of the browser throttling issue and how it can affect your tests
What causes ATF tests to fail? There are several possible root causes for this, including the tester failing to open the Client Test Runner, logging out of the session, or clearing the browser history on another tab, which affects all tabs. But inadequate central processing unit (CPU) power due to browser “throttling” is often at fault. Our previous best practices post, How to avoid ATF Testing Failures, gives you the lowdown on this issue.
When testing a form, set fields critical to your business process to ensure they all work
When creating a test for a form, you may be tempted to take shortcuts and only set the form’s required fields, or fields that you’ve edited. We recommend setting form fields critical to your business process, so that every time you run the test you’re verifying these fields.
A field must be present on the form in order to set it with Set Field Values.
Use the Test Logs and Test Transactions to troubleshoot test errors
And finally, here’s a shout out to the Test Logs and Test Transactions that provide a treasure trove of information for troubleshooting. Check them first before contacting customer support – the reason why a test is failing is probably recorded in one of these lists.
These are easy to find. After running your test, click Go to Result and the Test Results page displays.
- Click the Test Logs tab to see a record of all the detailed information that the test can track, including browser console logs and other errors:
- Click the Test Transactions tab to see a record of all system transactions recorded during the test:
Ready to get started with ATF? In this video, we show you how to set up your first ATF test:
For more information:
Getting started with the Automated Test Framework (product documentation)
Build and run your first automated test (product documentation)
Jakarta Juices Up Automated Test Framework (ATF) (blog post)
Behind the scenes here at ServiceNow, the Knowledge Management and Multimedia teams work closely with subject matter experts to disseminate critical information to our customers. We’ve found that certain topics come up frequently, in the form of best practices that can help you keep your ServiceNow instances running smoothly. This series targets those topics so that you and your organization can benefit from our collective expertise. If you have a best practices topic you’d like us to cover in this series, please let us know in the comments below.
To access all of the blog posts in this series, see our NOWSupport best practices series list.