ServiceNow Test Automation: Best Practices
Whether you're testing ServiceNow with Selenium, Leapwork, ATF, or another tool, many of the same best practices for building your tests apply. In this blog post we give you an overview of what to keep in mind when building maintainable and scalable automation.
- Decide what to test: When starting out with automation, it’s better to start small, and then scale up. Create simple tests that are key to the user journey. Keep in mind that automation is intended for repetitive, predictable scenarios. For this reason, regression tests may be a good place to start, as you have likely run these tests many times before, and will continue to run them at every release. Focus on automating tests at the functional UI level, which ATF, Leapwork, and Selenium are all intended for.
- Impersonate the user experience: The purpose of testing is to ensure that users can perform the desired actions. But users can have different roles and behaviors, so you’ll need to build tests that can mimic those. Make sure you have the right user data at hand. With ATF you create a user within the system with the desired role. Once the test is complete, the user gets rolled back. With Leapwork and Selenium, you create a user in ServiceNow, and then impersonate by simply logging in as that person and performing the steps of the test while recording as you go.
- Systemize your tests: Having a good overview of your tests will help you maintain them more easily. It will also help ensure that you don’t create unnecessary duplicates. Selenium is difficult to get a proper overview with, as all tests are displayed in lines of code. ATF offers a better solution that lists your tests in a more user-friendly format. Leapwork displays tests in a flowchart-like manner, which can give you a quick understanding of which tests are in your suite, as well as what those tests do.
Selenium Test Suite
ATF Test Suite
Leapwork Test Suite
- Run tests in parallel: To ensure quick execution of tests, it pays off to run several at once. To do this, you need to make sure that your tests aren’t using the same data at the same time. Scheduling can also help ensure that your tests are running in the most efficient way possible - this is unfortunately a feature that you won’t get with a free tool such as Selenium.
Learn more about testing with Selenium in in our blog post: How to Automate Testing with Codeless Selenium
- Incorporate timeouts: When performing UI tests you may experience tests failing when automated, even though they pass when you perform them manually. Keep in mind that computers perform tasks much faster than humans, and so sometimes the computer cannot find a button or a field, simply because it hasn’t loaded yet. For this reason, it can be a good idea to add a wait to the task, letting it process for a few seconds, before it moves on to the next.
- Parameterize data: Keep your data outsourced, instead of hardcoding it into the test. By pulling your input data from an excel sheet or other sources, you can test many combinations within the same test, rather than making multiple tests. This might not make a big difference when you’re just getting started with automation, but down the line, as you scale your automation, you’ll see the advantages in the time you save on maintenance.
- Create atomic tests: It’s difficult to evaluate the outcome of a failed test, if it’s testing more than one thing at once. Therefore, define one thing to test, and build a test around that, instead of branching tests along several paths.
For more best practices on building maintainable and scalable test automation, read on in this blog post.
See how you can build ServiceNow automation quicker and more easily with Leapwork’s no-code automation platform in our ServiceNow webinar.