The CreatorCon Call for Content is officially open! Get started here.

Use AT to validate a choice is NOT in a list

George P
Tera Guru

Hello,

I have a use case for the Assigned to field where it is filtered based on several criteria.  I would like to create an ATF Test to validate that the invalid options are not in the list.  There does not seem to be an assert type associated with setting values on the form, it either succeeds and passes the test or does not succeed and fails the test.  I can't tell it to expect a failure and continue the test.

 

Any ideas?

6 REPLIES 6

Sardash
Mega Guru

@George P - To validate 'Assigned to' field values via ATF you can use Test Step - 'Field Value Validation' 

Sardash_0-1758177434350.png

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Ankur Bawiskar
Tera Patron
Tera Patron

@George P 

My thoughts

-> ServiceNow ATF does not directly support a built-in “negative assertion” step for reference or dropdown fields, meaning you cannot natively expect a value to be missing and have the test pass when it is.

-> best practice is to use the Field Values Validation test step to check for correct positive options (i.e., only the expected valid choices are available), but there is no out-of-the-box step to assert that a value is specifically “not present” in the dropdown for reference fields

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

This was how I was seeing it as well.  But the request is to remove invalid users and that is what I am trying to test.

 

Is there a script test that could access g_form to attempt to set the values?  The script would then handle the failure as success use case.  I just haven't found such a test step that would do this.

@George P 

you can try to use Run Server Side Script step.

But that's not full proof solution.

You will have to stay with ATF limitations.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader