02-10-2022 06:27 PM
Hi
I have a String result test that checks a revision string. As the revision can change I made the test limit and result the same, so the test passes. However I need to handle the exception when the limit and result is empty.
To do this I was thinking to use the pre expresion field to fail the test when the result is empty. But my coding skills aren't good enough.
Open to better ideas, and hope this explains the situation clear enough.
Hence he call for help.
02-11-2022 02:32 AM - edited 02-11-2022 02:44 AM
Hi RN888,
I think I understand what you mean. What about configuring the Limits of your String Test as shown below?
If the value returned from your test is an empty string then that is compared against "" (an empty string) test limit (and passes), otherwise the value return is compared against your expected version number (I have used "Version 1.0").
NOTE: The statement uses the Ternary Operator (the ?). It is a conditional expression. If the statement in the brackets (Step.Result.String == "") evaluates to TRUE then the bit to the left hand side of the ":" is used, otherwise the bit to the right-hand side of the ":":is used.
Hope this helps
Steve
02-11-2022 03:39 AM
Hi,
One way of doing it is given below :
Add a numeric limit step.
Configure it as below :
In the data source tab :
Len(Locals.str)
If the string length of your string is >0 i.e. string not empty then it willl pass else fail.
Ravi
02-21-2022 07:56 PM
Thanks Steve
Apologies for not getting back sooner. I was job jumped. And NI Admin are asking for a response. The conditional operator is what I need. I would supply you with working my solution, but I can't test it at the moment. TestStand 2020 is not showing variables correctly in the watch window. Yet they are showing in my logs. Something weird going on, but I digress. Thanks again.
My rough draft is either
In Limits
Locals.Rev_Limit = ( (Locals.PEBB_Recovery_Kernel_Rev == "" ) ? "No Rev" : Locals.PEBB_Recovery_Kernel_Rev )
or my prefered response which is a better representation of what happened.
In Module/Results
Step.Result.String = ( (Locals.PEBB_Recovery_Kernel_Rev == "" ) ? "No Rev" : Locals.PEBB_Recovery_Kernel_Rev )
This should give a result of 2.1.0.8 or No Rev
02-22-2022 09:23 PM
I ended up doing this. It is not as elegant as I wanted, but it does the job.
And used the first VI Fail Mode pre expresion to force the results,
and did not write to Step.Result.String in the Module
And then forced the Limits to an empty string
I did try to use a pre expression to determine which of the two would execute
But this created unwanted 'skipped' logging in our database, hence I went with the IF
solution