Service Now - ATF Notes & Best Practices

Wednesday May 20, 2020

ATF

ATF is ServiceNow’s automatic testing framework. Like all the ServiceNow tools, it’s OK. These are some notes, in no particular order, on ATF.

Application Design & Test Types

How we implement an application will drive what types of tests we create. Generally, we assume the following design conventions when talking about tests here:

  1. Put all application logic in Script Includes - Things like UI actions should generally just instantiate a Script Include, call a method and handle errors/output/redirection/etc…

  2. Script Includes (or their functions) should not use any global objects (e.g. if you need the current user, take a user as a parameter rather than using gs.getUser() in the method itself). To the extent that it is possible, they should be “pure”:

    The definition of a pure function is: The function always returns the same result if the same arguments are passed in. It does not depend on any state, or data, change during a program’s execution. It must only depend on its input arguments.

There are 2 general types of test to think about with ATF. Generally, they are UI tests run with an automated web browser and unit tests.

Best Practices

Users in tests

For testing users/roles/permissions (which is a must) create the user with the proper role(s) in the test.

You can specify the role when creating the user, and this makes moving tests across systems much easier, and anyone that has to maintain the test (including the author) will be much happier.