How to test Standard Change by Automated Test Framework – part 2

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');
grV.addQuery('name', 'change_request');
grV.addQuery('element', 'std_change_producer_version');
grV.query();
    
grV.next();
grV.default_value='923504cc47410200e90d87e8dee490e2';
grV.update();

In effect ATF will test Standard Change created from template and properly check read only fields.

How to test Standard Change by Automated Test Framework

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:

(function() {
    var gr = new GlideRecord('sys_dictionary');
    gr.addQuery('name', 'change_request');
    gr.addQuery('element', 'type');
    gr.query();

    gr.next();
    gr.default_value = 'standard';
    gr.update();    
})();