The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Nia McCash
Mega Sage
Mega Sage

Do you use ATF for your ServiceNow testing? Perhaps you are just starting out on your ATF journey. Test Data Strategies for a QA Automation Framework is a must read.

Below, I will go over how the options presented in the article translate to ServiceNow ATF. I have excluded option 4 from the article because I will not be covering performance testing in this post.

 

Option 1 - Hard-coded test data (AKA Creating static data for testing purposes)

Caution: If you were to migrate your tests to a different instance, you would also need to export the test data records since the tests would reference the data's sys_id. 

Example: you want to test the ITSM modules and you need to impersonate an ITIL fulfiller to test various fulfiller actions.

  1. Create a ‘dummy’ user and assign that user with the appropriate role(s). 
    This user would need to be exported to XML in order to move the tests that refer to this user record to a different instance.
    find_real_file.png
     
  2. Impersonate said user in various ITSM tests.
    find_real_file.png

 

 

Option 2 - Real Time Test Data Extract (AKA Querying existing data to use as test data)

This method assumes that the data exists in your system. In the example below, the test queries for an open/active problem to use and the test would fail if there were none to be found.

However, I find this to still be a relatively quick and useful method for getting test data that is highly likely to be available - for finding an active user to set as the Caller on the incident form. 

In my organization there is likely to be plenty of open, active incidents that I can use for certain tests without having to create a new incident. The kind of existing data that one can confidently rely on will differ based on the organization.  You will know what existing data is most reliable to use as test data for your organization

Example: you want to test the ability to associate an incident to a problem.

  1. Use a Record Query step to find an existing, active problem.
    find_real_file.png
     
  2. Reference the existing problem as part of your test.
    find_real_file.png

 

Option 3 - Real Time Seeding (AKA Including test data creation as part of the test)

Creating test users, tickets, and other records can be especially helpful in simulating a rare and/or complex condition that you may need to test (eg. the Caller is a VIP and the Incident is a P1 and today is a holiday/outside of regular business hours).

In general, even for simple conditions, I prefer this method of generating test data. Including steps that create test users, tickets, or other necessary data makes your test self-contained, transferable, and more reliable. 

The trade off is that your tests will take longer to create, especially if it requires a lot of test data.

Example: you want to ensure that only users who have a particular role and are members of a particular group can see a certain widget on the Service Portal.

The Create a User test step (new in New York version) is incredibly handy for this purpose. But even if you are running a version prior to New York, you can still...

  1. Create a User record using the Record Insert test step.
  2. Create a Group Member record using the Record Insert test step.
  3. Create a User Roles record using the Record Insert test step.
  4. Impersonate the created user in the following test steps.

 

What strategies are you using to maintain your ATF test data?

Comments
Jace Benson
Mega Sage

I'm a big fan of the "Option 3 - Real time seeding" aka "Self Contained" tests.

It's literally why I started the "atf repo" on https://atf.jace.pro

I have written about this before and in both situations I state you should create the data to test against.

https://jace.pro/post/2017-12-02-atf-thoughts/

https://jace.pro/post/2018-04-19-atf-setting-up/

nvinod
Kilo Contributor

Is there any ATF test cases for validating the language translations. Please suggest me??

Jace Benson
Mega Sage

Couldn't you just have the atf suite create a user, then create a user preference for the language of your choice to test?

Version history
Last update:
‎02-17-2020 01:50 PM
Updated by: