06-23-2009 12:54 PM
I am trying to setup a pre-step callback to verify test conditions and correct them if they do not match the needs of the applicable test step. I was going to assign the test conditions in the pre-expression of each test step, but unfortunately I have found that the pre-expression executes AFTER the pre-step callback. Is there any way to get around this? How can I get around this? (i.e. to assign step specific variables before executing the pre-step callback).
Thanks,
Sean
Solved! Go to Solution.
06-23-2009 03:08 PM
You could use a statement step just before that step to set them up? or.......
This is totally a hack but in your precondition (which is evaluated before the callback) you could say something like (Locals.MyString = "Hello") == Nothing?True:True. This way the variable gets set and the step will always get executed. Just combine this with your other preconditions if you have them.
Hope this helps some. I'm curious to know how it works for you.
Regards,
06-23-2009 07:06 PM
Can you use a property loader step? I guess that is adding a separate step but one property loader step can load a bunch of steps, and assigning variables is what it is for. If you use a prestep engine callback then that one callback will have to handle all your different steps. Precondition is the only other thing that executes before prestep.
cc
06-24-2009 02:36 AM
Hi Sean C.
One possible solution for your problem could be custom step type which would have Pre-Step substep which would verify/correct test conditions before main module executes (You can find more information about custom step types from TestStand Help).
The execution order (custom step type) is:
1. Preconditions
2. Pre-expression
3. Pre-Step subtep(s)
4. Main module
5. Post-Step substep(s)
6. Post-Expression
7. Status Expression
Regards,
Petterik
06-24-2009 07:34 AM
Petterik,
In that case why wouldn't you just use the Pre-Expression? It was already determined that wasn't possible because it wasn't early enough in the execution order.
If you use an expression step just before this step you can say Runstate.NextStep.blahblahblah.
Regards,
06-24-2009 01:42 PM
I have done some hacking of preconditions, and its even easier than the example above. Remember that in TestStand expressions the comma (,) separates logical expressions. But the return value of the expression is always the return value of the last expression. So if you separate two logical expressions in the preconditions with a comma, only the return value of the second one gets used as the precondition.
For instance, if you always want the step to run, you could use:
locals.myVar = 5, True
Or if you already have preconditions:
locals.myVar = 5, AllOf(RunState.Sequence.Main["ID#:"].Result.Status == "Passed", RunState.Sequence.Main["ID#:"].Result.Status == "Passed")
Also, there was some discussion of what order a step executed its actions. You can find this information in the TestStand Reference Manual in chapter 3. There is a table that lists the exact order of operations, including when the pre-step engine callback is fired.
06-24-2009 02:11 PM
Josh,
That is good to know. I didn't realize that about the return value for an expression. I always just did it like I showed above. Now I got some code rewriting to do. 😉
Thanks for the info,
06-25-2009 02:47 PM
Josh, jiggawax, et. al.,
The use of the precondition to reassign variables is effectively just what I was looking for. Hurrah!
I was afraid I was going to have to copy parts of my prestepcallback all over my main procedure to get it to work, and that would have been a major bore (as well as being ugly/hard-to-read/etc.)
Thank you very much for your help,
-Sean