How do you use stepResult.setFailed() correctly?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2020 09:58 AM
When I use the Run Server Side Script step and I set stepResult.setFailed() the step always results in a successful step when run. Even if that is the only line in script it say it is successful. Any help would be appreciated.
Example:
(function(outputs, steps, stepResult, assertEqual) {
stepResult.setOutputMessage('This is a test. I expect this to fail');
stepResult.setFailed();
})(outputs, steps, stepResult, assertEqual);
- Labels:
-
Automated Test Framework
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2020 07:09 PM
Hi,
Please go through below thread.
Please mark it as helpful (or) correct if it helps.
Thanks,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2020 09:37 PM
Hi Dean,
The method stepResult.setSuccess()
causes the step to succeed. The method stepResult.setFailed()
causes the step to fail.
Try this one-
(function executeStep(inputs, outputs, stepResult)
{ if (gs.nil(inputs.table))
{ stepResult.setOutputMessage(gs.getMessage("", 'table')); stepResult.setFailed(); return; }
}
If it's helpful. please mark helpful or correct.
Swapnil Soni
SNOW Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2020 05:39 AM
Well that is exactly how I am using it. However, my results are always returning successful results. Like I mentioned in my question description all I had in my test step was the output message and the setFailed() method call. After I run the test everything displays as "All steps passed - Succeeded in 0 seconds" and the status of the step is "Success".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2020 09:54 AM
Hey Dean,
I had the exact same problem, the setFailed didn't work for me, but if you throw an error the step fails because of it.
stepResult.setOutputMessage('Error Message');
stepResult.setFailed(); //doesn't work for me
throw 'Error'; //fails the script test step