ATF Record Validation Test Failed - why?

Nia McCash
Mega Sage
Mega Sage

I've been experimenting with the Automated Test Framework and I'm finding lots of quirks.   Here's one that I hope someone in the community can help with...

I have a Record Validation test step which is just checking for the 'Active' flag on a record.   The only two options are true or false, (the test step config doesn't give any other options) but it doesn't matter which I select, the test always fails. Why?

Here is the test step setup:

ATF-record validation.jpg

I've confirmed that a matching record was found in both cases but both tests fail:

ATF-record validation fail1.jpg

ATF-record validation fail2.jpg

1 ACCEPTED SOLUTION

Nia McCash
Mega Sage
Mega Sage

So, in my case, this turns out to be a stupid error on my part.   The user (with no roles) that I was impersonating didn't have permissions to query/read the active field.  



Lesson learned: when impersonating, remember to keep in mind the permissions that to which the impersonated user has access!


View solution in original post

13 REPLIES 13

Geoffrey2
ServiceNow Employee
ServiceNow Employee

I encountered a few issues like this when I worked on an ATF project.   I found that if you were testing something on the Server side and it *should* work but doesn't, then you need to put a wait in. Maybe the record is still being committed to the database or something. I'm not sure, I'm not a doctor. Try adding a few seconds to the Timeout field. Or do this:



Create yourself a new Step Configuration that uses gs.sleep().   Eg:



gs.sleep(3000); // Wait for 3 seconds



This makes your script pause for the defined number of milliseconds before continuing.   Just what you need when waiting for a database commit.



I found that I needed it quite often, so I created a custom Step Configuration that had a number of seconds as an Input. Then I'd have Test Steps like this:


  1. Record Insert
  2. Wait
  3. Record Validation

Hi Geoffrey,



I tried adding 5 seconds to the Timeout value of the Record Validation step and that didn't do the trick.



So I tried configuring a test step as you suggested but I'm not sure I'm doing it correctly.   Can you advise?



This is my code for the Step Configuration's Step execution script:


(function executeStep(inputs, outputs, stepResult) {


      var miliseconds = 1000 * inputs.u_seconds;


      gs.sleep(miliseconds);


}(inputs, outputs, stepResult));



For the code above, I even tried with a simple, static value as you suggested:


gs.sleep(3000); // Wait for 3 seconds  



Either way, my test still fails, this time at the custom step configuration.   Strangely enough, even though the test run tells me the test failed, the test results log shows those tests as pending.  


ATF-pending.jpg



Have I incorrectly created my step configuration somehow?


I figured out the problem with my Step Configuration.   I needed to provide a step result.   This code for the step configuration now works


(function executeStep(inputs, outputs, stepResult) {


    var miliseconds = 1000 * inputs.u_seconds;


    gs.sleep(miliseconds);


    stepResult.setSuccess();


}(inputs, outputs, stepResult));



BUT, my Record Validation step is still unexpectedly failing even after waiting 10 seconds.


Geoffrey2
ServiceNow Employee
ServiceNow Employee

Sorry, I can't tell you why without digging around the instance.   I suggest you log it on Hi.   Even I had to log several Incident on Hi when I worked with ATF.   There are a number of bugs they are still sorting out.