ATF - How to trigger an ATF Test Suite when an Update Set is moved to Commit state

Siddhartha6
Tera Contributor

Hi All,

I am trying to create a BR that will launch an ATF test suite when any Update Set is moved to "Committed" state, but the BR is not triggering the ATF suite automatically, what should I do to fix it.

Table:
sys_remote_update_set


Details of BR:

SCR-20250218-qkgu.png

Script:

(function executeRule(current, previous) {
gs.log('Business Rule Triggered');
if (current.state == 'committed') {
gs.log('Update Set Committed');
// Trigger the ATF test suite
var atf = new GlideRecord('sys_atf_test_suite');
if (atf.get('name', 'YourTestSuiteName')) {
gs.log('Test Suite Found: ' + atf.sys_id);
var atfTrigger = new GlideRecord('sys_atf_test_suite_result');
atfTrigger.initialize();
atfTrigger.setValue('test_suite', atf.sys_id);
atfTrigger.setValue('status', 'ready');
var resultSysId = atfTrigger.insert();
gs.log('Test Suite Result Created: ' + resultSysId);
} else {
gs.log('Test Suite Not Found');
}
} else {
gs.log('Update Set Not Committed');
}
})(current, previous);

The BR is in "Active" state
#AutomatedTestFramework #ATF
1 ACCEPTED SOLUTION

Pooja2998
Mega Sage

Hello @Siddhartha6 ,

1) You need to create one Suite Schedule:

Create a Suite Schedule
Go to Automated Test Framework (ATF) -> Schedules and create a new Suite Schedule. (Run as On demand)

In the related list, add the Test Suite you want to run.

Pooja2998_0-1739958644472.png

 

2)Business Rule: write this code (  Replace with the actual Sys ID of your schedule )

(function executeRule(current, previous /*null when async*/) {

    var scheduledRunSysId = 'e3786e79833f5210a411faa6feaad3c5'; // Replace this with the actual Sys ID

        new sn_atf.ScheduledRunsExecutor().setScheduleSysId(scheduledRunSysId).start();

        gs.log('ATF Scheduled Run Started for Sys ID: ' + scheduledRunSysId);

})(current, previous);

Pooja2998_1-1739958693988.png

 

3)Make sure That  Scheduled Client test Runner  is open

 

If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Pooja.

View solution in original post

1 REPLY 1

Pooja2998
Mega Sage

Hello @Siddhartha6 ,

1) You need to create one Suite Schedule:

Create a Suite Schedule
Go to Automated Test Framework (ATF) -> Schedules and create a new Suite Schedule. (Run as On demand)

In the related list, add the Test Suite you want to run.

Pooja2998_0-1739958644472.png

 

2)Business Rule: write this code (  Replace with the actual Sys ID of your schedule )

(function executeRule(current, previous /*null when async*/) {

    var scheduledRunSysId = 'e3786e79833f5210a411faa6feaad3c5'; // Replace this with the actual Sys ID

        new sn_atf.ScheduledRunsExecutor().setScheduleSysId(scheduledRunSysId).start();

        gs.log('ATF Scheduled Run Started for Sys ID: ' + scheduledRunSysId);

})(current, previous);

Pooja2998_1-1739958693988.png

 

3)Make sure That  Scheduled Client test Runner  is open

 

If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Pooja.