ATF: Parameterized tests - is it possible to change assert type based on parameter values?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2022 04:16 AM
Hello, all! I have a question regarding parameterized testing in ATF and I have not been able to find this info, so I am hoping someone out there can help.
I need to build some tests to validate the access of different roles to records in a custom table. I'll give you a simple example:
Test A - Create a new record in table XYZ
- role '123' is able to create new records
- role '456' is not able to create new records
I created Test A as a parameterized test, with one parameter - the user role. I then created 2 data sets: one for role '123' and another one for role '456'. My problem is that it does not seem possible to use the same test to assert the 2 different scenarios:
- Test A step 1: create and impersonate user with the role that is in the parameter value
- Test A step 2: assert that the record was created --> the record is only created for role '123'; when the test runs for the second parameter, role '456', it fails
Is there some way to change the assert type so that it validates that the record was created for role '123', but then validates that it was NOT created for role '456'?
My solution for now is to duplicate these tests so each one has a different assert, but this seems cumbersome and generates a lot of repeated steps and extra work (even though I am using templates, it feels like there should be a better way to accomplish this).
Thanks in advance 🙂
- Labels:
-
Automated Test Framework

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 09:44 PM
Hi Ana
I see the challenge with low code solution. Will you be able to use the step 'Run server side script' as Step 2? You can use the query like below:
var grXyz = new GlideRecordSecure('XYZ');
grXyz.setValue('column_1', 'someValue');
var newRecordId = grXyz.insert(); //This returns sysID if insert is successful, null otherwise
var testAssertion = {
name: "Validate record insertion",
shouldbe: params.expected_insert, //expected_isnert is the boolean parameter
value: JSUtil.notNil(newRecordId),
};
assertEqual(testAssertion); // throws Error, logs message to test step output
--
Best Regards
Ankush
P.S. Please mark helpful/correct as appropriate to help the fellow community member in identifying the relevant answers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2023 12:31 PM
@Ankush Agrawal Relevant question. Appreciate any inputs.
I am using custom UI Step config, and is it possible to assign a value to an output variable or a shared/exclusive parameter from within the executeStep script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2023 10:57 PM
Hi Shan
Thanks for reaching out. UnfortunatelyerviceNow does not allow the customisation or new creation of the Custom UI step due to the maintenance and stability aspect of them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2023 04:52 AM - edited ‎04-20-2023 06:02 AM
Thanks.
I am able to create new custom UI step config(using coping an existing Custom UI Step Config), and been using for some days since Paris. I understand, lot of limitations are there as this is just evolving, and would like to know if the output variables value assignment is possible.