Welcome to part 14 of the Builder series.
In this video, we’ll show you how to create functional tests for your application...
... to expedite upgrades to your ServiceNow instance and ensure that your app releases are as high quality as possible.
This video builds on the use case from previous videos in this series and references the Safety application built earlier.
Luke, our Safety Manager, has many more features he’d like to add to the Safety application.
To ensure that our future changes don’t interfere with any work we’ve done to date...
... we’ll build some functional tests.
That way, we can make sure the app is running as designed before it gets to production.
We’ll begin by navigating to Automated Test Framework, also referred to as ATF, and click Tests.
From the list, we create a new Test.
This test will check one specific bit of functionality.
It’s going to ensure that the Due date field is hidden when the category is small.
So we’ll give it an appropriate name.
The prefix helps identify it as part of our safety application.
After saving it, we go down to the test steps and start by adding a new test step.
We select create new user and click Next.
Creating a new user ensures that the user running the test has the necessary roles to carry out the test.
If we were to run tests with an existing user...
... the test may fail at some point if that user were to change roles or leave the company.
We submit that…
…and one step is done, with only a few more to create.
It’s really pretty quick.
After the user has been created, we add another new step, and this time under Form...
...we open a new form and click Next.
The only information we need to provide here is which table to use...
... so we’ll select the Issue table and click Submit.
The next step is to set field values.
Because we already identified the table on the Open form step...
... the system automatically populates that field...
... so all we have to do is specify which other fields to set to which values.
The system has made the Inspector field mandatory, and it’s pre-selected for us.
All we need to do is set a value.
We’ll also set the Category field to Small…
…the Short description field to Automated test…
… the Location field to one of our locations…
… And instead of setting the Opened by field to a static value...
... we can insert the value of the user created earlier by clicking the input value icon and selecting the value dynamically.
And we submit that step.
Now let’s add a step to validate the field state.
We want to check that the Due date field is hidden...
... so we’ll add it to the Not visible list by moving it from Available to Selected and clicking Submit.
That’s it.
Our test is ready to run, so let’s click Run Test.
The system asks if we want to run a client runner.
This is so that it can test not only the backend server bits...
... but also things that happen in a browser, like our Due date field being hidden or displayed.
Over on the new tab, we see the test running….
And when it’s done, we go back to the first tab and see that it’s been successful.
If that weren’t the case, we would need to either update the application to meet new test requirements...
... or revise the test to meet some new application requirements that were implemented, but not yet part of the test.
Next to the list of steps, we can see the results of this test, including screenshots of the client as the test ran.
At this point, we can go back to the test...
... and either add steps to change the category to Big...
…and validate that the Due date field is visible...
Or copy this test and make minor changes to the Set Field Values and Field State Validation steps.
Either is acceptable.
With multiple tests, we may also want to consider creating a test suite so that we can launch a series of tests in one click.
We can use the condition field to find all of our tests quickly and stay up-to-date as new tests with the same prefix are created.
That’s it for ATF.
It’s built into the platform to give you confidence in the quality of your application...
... and shorten the testing time needed when upgrading to new ServiceNow releases.
Best of all, tests are quick to build and maintain!
For more information, see our product documentation, knowledge base, or podcast.
Or ask a question in the ServiceNow Community.