Automated testing in ServiceNow

Solana Beach, CA. | Mar 10th 2020
Why automate testing?

Over the last decade ServiceNow has become a fixture within the enterprise both inside and outside of the IT department. As more applications are moved onto the ServiceNow platform the burden of testing releases becomes greater. The vast majority of ServiceNow customers are still testing their own releases and ServiceNow upgrades manually. At DotWalk we refer to this as clickety-clackety testing. More often than not customers don’t have a written test plan, and are forced to beg, borrow and steal time from their own internal customers to test ServiceNow.

While it may not have become widespread in the ServiceNow ecosystem, test automation is practically a religion in the wider software development community. Practices like Test Driven Development have allowed developers to release more frequently and with higher confidence because they are leveraging automated testing to allow them to quickly validate their changes.

You’ve probably heard about the industry moving from waterfall to scrum, less frequent bigger releases to more frequent smaller releases. It is hard to overstate the role that test automation has played in enabling these changes in how developers manage their releases.

Test automation is a game changer for how you manage your ServiceNow instance. The time to embrace it is now because the more work you do on your instance without developing tests the more work you’ll have to do when you eventually get around to automating testing.

Test Automation on ServiceNow

Test automation for ServiceNow is about testing your customizations. If every customer had to write automated tests for every part of the ServiceNow platform it simply wouldn’t be feasible. Rather, ServiceNow has extensive automated testing for its platform, UI’s and out of the box functionality of its applications. What is left? Your customizations and your company’s specific workflow.

For testing ServiceNow the obvious (and correct) tool you should be using is ServiceNow’s Automated Testing Framework (ATF). ServiceNow invests heavily to provide a no-code solution for testing your applications written on the ServiceNow platform. ServiceNow’s ATF is included at no additional cost to customers. When you use ServiceNow’s own tool you have a strong guarantee of release over release compatibility. Don’t take the risk of using a non-ServiceNow testing framework.

What does an automated test look like and how does it actually work?

Automated tests have two types of steps: Actions and Assertions. Actions “do” something: Open a form, Input a value, or Submit a record. They put your system into a state where it’s ready to be tested but they don’t really do the testing. Assertions are the steps that say how the application should behave: Open the form (action), Validate that the Caller field is Read only and populated with the current user (assertions). Assertions are where you catch problems.

Additionally, automated tests will implicitly detect errors. An error happens when a part of the code that makes up the application is broken or has reached a boundary condition it doesn’t know how to handle. This ability to implicitly detect errors is where you get a lot of the value from your automated tests and also where they differentiate themselves from manual testing. Manual testers don’t watch error logs while they are testing. So while a manual tester will click around through a form and see that things seem fine, they’ll often miss the fact that a critical integration isn’t running because its throwing an error or that SLA’s stopped working because of some customization not being compatible with the newest release.

ServiceNow’s ATF can detect errors in your client code but it doesn’t detect errors on the server. DotWalk provides an error detection capability on the server through custom steps added to every test generated by Bootstrap. This is one of the critical reasons why our tests are so effective at catching regressions.

How to get started

The hardest part is getting started. While test automation comes with the promise of saving your organization hours of time in the long run, in the short term you have to write your tests. If you have a mature instance of ServiceNow with customizations to OOB applications then in order to test your workflow you’re going to need to know what it is.

It’s best to think of your ServiceNow instance as a tree of use cases. Each form is a starting point for a branch of use cases. Forms can have different views with different fields and behaviors. Additionally depending on the roles a user has, users will have different behaviors and access in the system. Unfortunately, to truly test the full depth of use cases it’s necessary to look at all the possible combinations of these use case variables. We’re starting to talk about a lot of tests and we haven’t even mentioned different inputs to these applications where business logic pivots on different values inputted to a field. If this sounds daunting, take a breath, then accept that you will never get to 100% test coverage of each and every possible scenario.

Part of the reason that getting started is so hard is because it can be so overwhelming to think about all the work that must be done. If we don’t allow perfection to be the enemy of good, a reasonable goal for any organization to set is to have more test coverage automated than what is currently provided through the current manual testing process.

So no, really, how do I get started…?

Call DotWalk and buy Bootstrap. It will generate hundreds of highly detailed, automated tests that run in ServiceNow’s automated testing framework with the click of a button. It's like nothing else out there on the market because it actually automates the process of automating your testing. That’s automation cubed: DotWalk automates the process of automating the system that automates your workflows!

Still not convinced? That’s OK. Short of using Bootstrap (which is really a better option) the next best way to get started is to check out the tests that ServiceNow ships out-of-the-box. These tests are static. They will “pass” on an out of the box instance but probably don’t reflect the reality of anyone’s applications that is reading this article. That said, since the hardest thing is to get started, it's a lot easier to take one of these and start modifying it to match the particulars of your instance.

What haven’t you told me?

A whole lot, for sure! The documentation for ServiceNow’s ATF is your best bet to understand specifics on how to create tests. Hopefully this guide has done enough to convince you of the benefits of test automation that you want to take that next step. There are many advanced topics out there like, custom UI and Service Portal testing, that we’re not covering here. Know that anything is possible. There aren’t really any restrictions on what can be tested.

Because ServiceNow professionals don’t have experience with automated testing it can be difficult to imagine what the world looks like once you’ve made this transition. The short version is: it’s better! But like anything else, this is not a silver bullet. One of the keys to success with test automation is running your tests frequently (fail fast).

If you run your tests nightly it gets alot easier to debug them when there are failures. Remember that the tests will only tell you that something isn’t working but they won’t tell you why. If it's been 6 months since the last time you ran your tests it can be difficult to figure out what actually changed in the system to cause the failing test. If you run your tests nightly though, most people can generally remember what happened in the last 24-48 hours. Additionally, by catching problems in development you avoid interruptions to your release schedule. At DotWalk we provide a service that allows you to schedule your tests.

While scheduling is built into the ServiceNow Automated Test Framework it requires you to have a browser pointed out and there can be issues with browsers timing out and crashing that make it really difficult to manage. Our service takes that burden off you by providing browsers that run on-demand and are highly reliable.

In conclusion

You should really make implementing (at least some) test automation part of your 2020 planning. Give us a call and let us show you how DotWalk “Bootstrap” can make the process of automating your ServiceNow testing dramatically easier. Our customers are immediately able to upgrade their instances twice as fast and with much higher quality.

Jared Laethem is a software engineer and CEO of DotWalk. Jared spent 10 years working at ServiceNow, the majority spent helping build and lead teams that built parts of the ServiceNow platform including its upgrade systems and the ServiceNow Automated Testing Framework.