NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I stop on failure?

Solved!
Go to solution

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?

0 Kudos
Message 1 of 13
(9,143 Views)

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

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 13
(9,138 Views)

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?

0 Kudos
Message 3 of 13
(9,134 Views)

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

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 13
(9,133 Views)
Solution
Accepted by topic author tlaford

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

Message Edited by dug9000 on 05-19-2010 09:06 AM
Message 5 of 13
(9,120 Views)

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;

 

0 Kudos
Message 6 of 13
(9,108 Views)

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"?

0 Kudos
Message 7 of 13
(9,104 Views)
 I do not think these settings require tracing so you don't need tracing on unless you want it. I think the other idea that was posted about using trace UIMessages is what the enable tracing was for, but I don't think that's necessary for these settings.

 

-Doug

0 Kudos
Message 8 of 13
(9,054 Views)

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

0 Kudos
Message 9 of 13
(9,053 Views)

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?

0 Kudos
Message 10 of 13
(9,001 Views)