NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom step and step execution

Solved!
Go to solution

Hello,

I am in need of the solution for accessing the execution of a Step

The execution order of a step begin as below.  How can I insert a custom call at  execution position before step 3 and after step 18?

Can I create a custom step allow me to insert a function call like that

1-->Allocate result

2-->Enter batch synchronization

3-->Check Run mode for Skip

4-->evaluate precondition

....

17-->Evaluate Post expression

18-->Evaluate Status Expression

 

0 Kudos
Message 1 of 8
(4,246 Views)

Hey Tphan,

 

I can think of a few ways to accomplish this. Unfortunately, it's not really possible to insert something in the step itself that will always excecute before the run mode is evaluated, because the purpose of the run mode is to determine whether or not the step should execute. One simple solution to this would be to insert a Statement step directly before the step in question. This would execute before the step in question, and makes a bit more sense visually, especially if the step is set to Skip.

 

Another option is to override the SequenceFilePreStep callback, which executes before every step in the sequence. If there was something you needed to do before every step, it would make sense to put that code in this callback. There's also a SequenceFilePostStep callback, which would execute after each step completes. 

 

Either of these options would work for what you're trying to do, and I think they might make more sense in terms of setting up the sequence in an ideal way so that its functionality will be apparent to any other test developers examining the code. Hopefully this will help some, but if you do have more questions about it, it'd be great to have a bit more information about what kinds of things you want to do in these pre- or post-steps. 

0 Kudos
Message 2 of 8
(4,229 Views)

Hello Daniel-E

Thanks for replying.

I am trying to create a custom batch model which is:

-If a step failed, all steps after that is report skip and the test is stop.  It is crucial that all the steps will be report does not matter pass or fail or skip

-This function can be switch on /off using property loader from a text file

-Only work on custom step time to limit resource uses

As this could easily done by putting (fx) functions before and after a step to :

-Precheck if a fail flag is occured then setting the step to skip or Force Fail

-Postcheck if a the step status before is failed to set a flag

However putting step (fx) before or after will make the test seq looks confusing and time consumming when writing a test sequence.

Precondition can be use for dynamicly setting the step to skip or fail, but limit to boolean only

The post expression is before Status evaluation so it can not tell that the step status is pass or fail

using the call back for pre and post might work but add a lot more of cpu time since it apply to every steps but might  be an acceptable solution.

I am going to check it out

Thanks for helping

Tphan

0 Kudos
Message 3 of 8
(4,216 Views)
Solution
Accepted by topic author Tphan

@Tphan wrote:

Precondition can be use for dynamicly setting the step to skip or fail, but limit to boolean only



The above statement is not correct, you can have any expressions as long as they evaluate to a true or false. So for example, you can have a precondition:

RunState.PreviousStep.Result.Status=="Passed"

So the above expression makes sure that the step will only execute if the previous test passed.

I think your problem can be solved using pre-conditions and post actions.

Have a look at the attached file.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 4 of 8
(4,212 Views)

Yes indeed it is a solution.  How ever since what I do is a Model.  I want to conceal the expression for other developer want to use precondition and post expression.

They not look clean but it should work,

Thanks

Tphan

0 Kudos
Message 5 of 8
(4,209 Views)

Hello,

I try to open the seg in Teststand 2012 but got a message "CreateProcess Fail".

Does the seg file corrupted?

Thanks

Tphan

0 Kudos
Message 6 of 8
(4,199 Views)

Not sure of the error, I can still open it.

Here is one in 2010 format.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 7 of 8
(4,189 Views)

Thanks, That works

Tphan

0 Kudos
Message 8 of 8
(4,183 Views)