07-15-2013 10:13 PM
Could you please let me know how can I set a precondition based on a local variable so when the variable is 1 I can skip a test or when it is zero I programatically set the run mode to normal.
Thanks
07-16-2013 03:51 AM
Each step has a pre condition property which you can use.
Click on the step and go to its step properties.
Go to the pre condition statment and type locals.x!=1
If locals.x is not equal to 1 this step will execute else it will be automatically skipped.
Hope this helps.
07-16-2013 08:56 AM
Preconditions and runmode are two completely separate things. I'm not sure why you need both, please explain. If a precondition evaluates to false then the code modules for the step are not run, there is no need to set the runmode to skipped.
-Doug
07-17-2013 08:36 AM
I have a case where I use the Pre-Condition to skip some steps (subsequence call) for a specific test) if that test has run successfully already.
This is handled in a 'SequenceFilePostStep", thus the "RunState.Caller....".
The Precondition is set to 'False' so it won't run.
'Set the Precondition on the next step to "False 'Remove" (The remove is to indicate that it will be removed later so it's not saved in the sequence file.)
Locals.sPreviousPrecondition1 =RunState.Caller.Sequence.Main[RunState.Caller.RunState.NextStepIndex].Precondition,
RunState.Caller.Sequence.Main[RunState.Caller.RunState.NextStepIndex].Precondition ="False 'Remove"& Locals.sPreviousPrecondition1
The "False 'Remove" needs to be removed later, or it will be saved in the file and remain. This is accomplished later with:
'Need to copy the contents to a Local variable, manipulate it to remove the "False 'Remove" string then re-assign back into the Precondtion
Locals.sPreviousPrecondition1 = RunState.Caller.Sequence.Main[RunState.Caller.RunState.PreviousStepIndex].Precondition,
Locals.sPreviousPrecondition1 = SearchAndReplace(Locals.sPreviousPrecondition1,"False 'Remove","",0),
RunState.Caller.Sequence.Main[RunState.Caller.RunState.PreviousStepIndex].Precondition =Locals.sPreviousPrecondition1
Mike
07-17-2013 09:01 AM - edited 07-17-2013 09:02 AM
I'm still not sure how changing the runmode comes into play.
Why not just have the preconditions check whatever the post step is currently checking?
What exactly is the problem you are trying to solve? How does runmode help you solve it?
-Doug
07-18-2013 08:34 AM
Doug,
In my case, I have a master sequence that call each of about 200 different tests. Once these tests have run, the report output name is renamed using the format:
ErrorCount, ProductName and build as prefixes:
0-RMC Bld=78 Counter_Interface_NonVolatile.seq
If for some reason, I restart the master test, and the "Counter_Interface_NonVolatile" test has run successfully for this product and build, I don't need to re-run it. In the SequenceFilePostStep callback, I have a C# DLL that I use to determine if the test has run successfully in the recent runs. If it has, then I mark the next test to "Skip" using the Precondition.
Because this edits the step, I need to remove it after the master sequence has gone by it.
Mike
07-18-2013 08:49 AM - edited 07-18-2013 08:53 AM
There is a simpler way to do what you are trying to do:
1) Use the SequenceFilePreStep callback (rather than the post step callback)
2) If you want to keep the current Parameters.Step from executing do this in an expression step from inside the SequenceFilePreStep callback:
Parameters.Step.CancelCurrentExecution = True
You don't need to unset the cancelling it is automatically unset the next time the step is executed (or on the next loop iteration if the step is set to loop). See the API help for Step.CancelCurrentExecution for more details. NOTE: When you use this feature the step's status will be set to Done. If you don't like that then another possibility is to use the runmode setting in the post step, specifying an execution for the runmode makes it apply only to that execution, but it does still need to be reset back to normal if you are going to execute the step again for that execution. If you prefer that approach look at the API help for Step.SetRunModeEx.
Hope this helps,
-Doug
07-18-2013 08:51 AM
Thanks Doug, when I get a chance, I'll try that approach.
Mike
07-18-2013 08:53 AM
NOTE: Actually I just realized you can change the status in the prestep callback as well so you can use the first approach like this to also change the status to skipped if you prefer (This is probably better and easier than using SetRunModeEx):
Parameters.Step.CancelCurrentExecution = True, Parameters.Step.Result.Status = "Skipped"
-Doug