Automated Test Framework for Transform Maps

mauricio_paloma
Tera Expert

Greetings!

I wanted to see how we can create an Automated Test Framework ( ATF ) for Transform Maps.

Looking for ideas or examples.

Thanks!

1 ACCEPTED SOLUTION

collin109
Tera Contributor

Hello,



I have recently set up automated testing for transform maps and below I've outlined a basic summary of what needed to be done and how it was done.



In the Automated Test Framework I'm testing against a table that extends import_set_row   (along with a corresponding form) named Server Import and a transform map with a source table of Server Import and a target table of Server [cmdb_ci_server].   The transform map has an onBeofre script that will modify the target table of the transform map to a more precise CI class such as Windows Server [cmdb_ci_win_server] or Linux Server [cmdb_ci_linux_server] based on the value of a column in the Server Import table.



I'm testing to verify that when a record is inserted into the Server Import table a new record is created in the correct CI class table based on the onBefore script and that all the mapped columns from the target table in the transform map hold the correct values from the source table.



I created a new test in the automated test framework which only uses out of the box test steps. This test contains a total of 7 test steps as follows:



Impersonate


(While this step may not be necessary it will standardize the test runner and if using an account unique to testing, it will prevent client-side scripts from being interfered with by a user doing other manual operations in the ServiceNow instance while the test is running as client-side scripts require that a client test runner is executing in the users browser)


Open a New Form (client-side)


The Server Import form


Set Field Values (client-side)


A record was used from the scheduled import csv file, which meet conditions necessary setting each column in the source table Server Import


Submit a Form (client-side)


This sends the record to the server and executes the transform map


Record Query


This step is used to query the cmdb_ci tables that the transform map should have inserted data into, specifically the Windows Server [cmdb_ci_win_server] (our test data should have caused the onBefore script to change the target table from cmdb_ci_server to cmdb_ci_win_server) Note while many where clauses can be used to query a record (such as all the mapped values) I perfer to use just the unique id and then validate data through the forms as in the steps below


Open an Existing Record


This step is used to take the query result from the previous step (using a contextual value referenceing the previous steps resulting document Id) and open it in the form corresponding to the cmdb ci class table (cmdb_ci_win_server)


Field Values Validation


Once the record is open in the form, data in the columns can be verified against the original test record from the server_import table



Of note is that anything you want to test has to be included in a test and test steps as the Automated Test Framework rolls back all changes to data once the test is completed and you will not be able to manually validate anything.



From here you can create additional test to verify each conditional possibility of the onBefore script and then add all the tests to a test suite.



I hope this helps.



Thanks.


View solution in original post

4 REPLIES 4

collin109
Tera Contributor

Hello,



I have recently set up automated testing for transform maps and below I've outlined a basic summary of what needed to be done and how it was done.



In the Automated Test Framework I'm testing against a table that extends import_set_row   (along with a corresponding form) named Server Import and a transform map with a source table of Server Import and a target table of Server [cmdb_ci_server].   The transform map has an onBeofre script that will modify the target table of the transform map to a more precise CI class such as Windows Server [cmdb_ci_win_server] or Linux Server [cmdb_ci_linux_server] based on the value of a column in the Server Import table.



I'm testing to verify that when a record is inserted into the Server Import table a new record is created in the correct CI class table based on the onBefore script and that all the mapped columns from the target table in the transform map hold the correct values from the source table.



I created a new test in the automated test framework which only uses out of the box test steps. This test contains a total of 7 test steps as follows:



Impersonate


(While this step may not be necessary it will standardize the test runner and if using an account unique to testing, it will prevent client-side scripts from being interfered with by a user doing other manual operations in the ServiceNow instance while the test is running as client-side scripts require that a client test runner is executing in the users browser)


Open a New Form (client-side)


The Server Import form


Set Field Values (client-side)


A record was used from the scheduled import csv file, which meet conditions necessary setting each column in the source table Server Import


Submit a Form (client-side)


This sends the record to the server and executes the transform map


Record Query


This step is used to query the cmdb_ci tables that the transform map should have inserted data into, specifically the Windows Server [cmdb_ci_win_server] (our test data should have caused the onBefore script to change the target table from cmdb_ci_server to cmdb_ci_win_server) Note while many where clauses can be used to query a record (such as all the mapped values) I perfer to use just the unique id and then validate data through the forms as in the steps below


Open an Existing Record


This step is used to take the query result from the previous step (using a contextual value referenceing the previous steps resulting document Id) and open it in the form corresponding to the cmdb ci class table (cmdb_ci_win_server)


Field Values Validation


Once the record is open in the form, data in the columns can be verified against the original test record from the server_import table



Of note is that anything you want to test has to be included in a test and test steps as the Automated Test Framework rolls back all changes to data once the test is completed and you will not be able to manually validate anything.



From here you can create additional test to verify each conditional possibility of the onBefore script and then add all the tests to a test suite.



I hope this helps.



Thanks.


Could you please elaborate it . 

here i would like to update Manger field in sys_user table by using Excel sheet.

So how can we do it.

mean while here, we are getting confusion on steps.

step 1: in which table we should take new form

step 2: what is Server import

step 3: set field value: what i have to set field values here.

where we have to take Target table, where we have to upload Excel sheet here.

 

Could you please help me here, 

Hi,

How to open a mapped field to verify source and target fields are correctly mapped.

 

Here, I want click on "u_area" or "info icon and then open record" to open the record and verify mapping.

 

I tried using Click Component (Custom UI) --but I couldn't find any mapped components in retrieved .

 

Could you please help me here.

chaitanya2948
Tera Contributor