NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

If Statement vs Precondition - Which one is best practice?

What is best practice for when to use an If Statement vs Precondition to determine which code to run?

 

If Statement Example,

If A

   then Run B;

If C

   then Run D;

 

OR.............

 

Precondition Example For Same Code Above,

Precondition A then Run B

Precondition C then Run D

 

Thanks!

0 Kudos
Message 1 of 3
(1,591 Views)

Depends on whether you want it to show explicitly or not.

 

Typically, you use IF statement if the logic is part of the test program logic and you use pre-condition if that logic is part of the framework.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 2 of 3
(1,589 Views)

To add to santo_13

 

I do prefer explicit IF statements in my test code. It ay bloat the code a bit, yet at the same time making it more readable. 

Using PreConditions, things rather get hidden and vanish within in the settings coloumn of the Seqeunce Pane.

 

Same thing holds true e.g. for looping or synchronization settings.

 

Someone will have to debug the code.... do them (or yourself) a favour  and  leave something easy to read and understand.

Message 3 of 3
(1,570 Views)