Recently I was asked for providing report with summary information about configured tests.
I’ve created a Database View to have it ready for the future requests (I’m expecting that sooner or later I’ll be asked again for the same).
The scheme is very simple:
The update set with this Database View:
This time I would like to present how to create very first unit test and adapt TDD for creating scripts in ServiceNow.
I’m going to create two very simple script includes: Course and Student.
The course will be implemented three methods:
Continue reading How to start with TDD in ServiceNow
In this post I’m going to describe how to create a new test step. I’m going to create a step for selecting Change Requsest type. I’ll can use this step to determine wich type of change I would like to test.
Continue reading How to configure new test step
Problem with testing Read Only fields
Once you are ready to test Standard Change by using guide described here: How to test Standard Change by Automated Test Framework you’ll soon discover that ATF doesn’t check Read Only Fields correctly.
To avoid this problem you have to set default value for Standard Change Template version. To do this you need add the following code to the Server Side Script prepared in previous post.
var grV = new GlideRecord('sys_dictionary');
In effect ATF will test Standard Change created from template and properly check read only fields.
If you try to test standard change by using automated test framework you’ll soon find out that there is no easy way to test this type of change. Because during test execution you can’t open a page which allows you to select standard change:
You can add a new record by out of the box test step ‘Open a New Form’ but it creates default type of change (OOTB it’s Normal Change).
A workaround for this is changing the default value for change type during test execution. So before opening a new form add server side test step: ‘Run Server Side Script’.
And finally by the following query you can change the default value for change type:
var gr = new GlideRecord('sys_dictionary');
gr.default_value = 'standard';