05-19-2010 07:21 AM
We have developed a C# application that manages the execution of a test sequence. Currently, our code initiates a test execution via the call:
seqFileViewMgr.GetCommand(CommandKinds.CommandKind_ExecutionEntryPoints_Set, 1).Execute(true);
and it detects the completion of a test execution via the EndExecution event, and I determine the overall status by looking at the Execution.ResultStatus in my EndExecution event handler callback.
They have changed the requirements and I now need to detect the status of each step and (if requested) stop the test execution when a step fails. Can someone please enlighten me as to what changes I need to make to my design to achieve this step-by-step monitoring?
Solved! Go to Solution.
05-19-2010 08:10 AM
I suggest you to use callback sequences in your SequenceFile to solve this.
Nevertheless, the following code should take you in the right direction:
private void axExecutionViewMgr_Trace(object sender, NationalInstruments.TestStand.Interop.UI.Ax._ExecutionViewMgrEvents_TraceEvent e)
{
if(e.ctxt.SequenceFailed)
textBox1.Text = "FAILED";
}
hope this helps,
Norbert
05-19-2010 08:34 AM
Thanks. But let's also consider attacking this problem from another direction.
Is it possible to set some property via the TestStand API that would tell TestStand to stop the execution if a step fails?
05-19-2010 08:41 AM
Instead of changing the text within a textbox, you could simply use the reference to the execution (e.exec) to do one of the following:
- Abort (not recommended)
- Break (just like running into a breakpoint)
- Terminate (shutdown execution "properly")
If you choose break, do not forget to introduce options for the user to continue the execution either by manual stepping (step into/step out/step over) or by simply resuming it.
One important note:
This will only work if you have tracing enabled! If tracing is disabled, the TestStand engine does not generate the Trace event!
hope this helps,
Norbert
05-19-2010 09:05 AM - edited 05-19-2010 09:06 AM
There are some features which might be of interest to you.
Break on Failure - A toggleable setting located underneath the execute menu in the sequence editor and also settable via the API with StationOptions.BreakOnFailure or StationOptions.BreakOnSequenceFailure
Goto Cleanup on Sequence Failure - This is a setting at the bottom of the first page of the station options dialog and can also be set per sequence in the sequence properties dialog. It can also be set programmatically using Sequence.GotoCleanupOnFailure or StationOptions.AlwaysGotoCleanupOnFailure.
SequenceFilePostStepFailure callback - This is a special callback sequence you can create in your sequence files that will get called whenever a step fails. You can add special code to this callback to customize what happens when a step fails in many different ways.
Hope this helps,
-Doug
05-19-2010 09:52 AM
Success!
I added these two lines and it works great!
this.axApplicationMgr.GetEngine().StationOptions.BreakOnStepFailure = true;
this.axApplicationMgr.GetEngine().StationOptions.AlwaysGotoCleanupOnFailure = true;
One last question: Should I also include the following line:
this.axApplicationMgr.GetEngine().StationOptions.TracingEnabled = true;
05-19-2010 10:11 AM
One more question (after the one I already asked):
How can I tell the difference between an execution that completed normally (either passed or failed) and an execution that stopped early because I set the BreakOnStepFailure flag?
Is there a read-only property I can look at or do I need to add a check for
"if ResultStatus == "Failed" and BreakOnStepFailure == true"?
05-20-2010 11:37 AM
-Doug
05-20-2010 11:40 AM
tlaford wrote:One more question (after the one I already asked):
How can I tell the difference between an execution that completed normally (either passed or failed) and an execution that stopped early because I set the BreakOnStepFailure flag?
Is there a read-only property I can look at or do I need to add a check for
"if ResultStatus == "Failed" and BreakOnStepFailure == true"?
The step's status and sequence's status will be the same either way. You can check to see if the station option is set to true as you suggested if you want to know if that setting is enabled.
-Doug
05-24-2010 02:34 PM
Your suggestion to use the Trace event might be able to address a different capability I need.
e.ctxt.SequenceFailed indicates that the current step or a step prior to the current step has failed. But what if I am only interested in the success or failure of the current step without being influenced by previous successes or failures?