09-08-2011 08:25 AM
I have a property in my step types for TestNumber... I want to use this either hard coded or programatically... so as a preexpression I put in a statement of:
PropertyExists("Locals.TestNumber")?Step.TestNumber=Locals.TestNumber:Step.TestNumber
My thoughts were... if the local sequence had a variable testnumber to use that, otherwise to use what was in the step property... this way some sequences could be programatic and others could be hard coded...
My problem is...
I'm getting an error/warning of expressions must evaluate to the expected type... and "unknown variable or property name" in regards to the locals.testnumber...
If I run it and ignore the error, it executes properly... updating the step.testnumber when locals.testnumber and using the step.testnumber otherwise... but what is causing the error? I thought that was the purpose of the propertyexists statement to check if something is valid before using it in an expression....
09-08-2011 08:57 AM
Put the expression in brackets eg
(PropertyExists("Locals.TestNumber"))?(Step.TestNumber=Locals.TestNumber):Step.TestNumber
09-08-2011 09:00 AM
It still gives an error regarding locals.testnumber not existing... but it shouldn't be evaluating that part of the conditional statement since the propertyexists should return a false when it doesn't exist...
09-08-2011 09:27 AM
I had the following in a Statement step and no errors
PropertyExists ("Locals.TestNumber" ) ? (Step.Result.ReportText = Locals.TestNumber) : (Step.Result.ReportText ="No" )
Locals.TestNumber doesn't exist in my Sequence
09-08-2011 10:02 AM
I figured out the problem and it was related to the TS Analyzer and rule "Expressions Must Evaluate to a value of the expected type"
If you don't have analyze before running enabled, you'll never see the error... if you run the analyze, that rule will cause an error... which isn't really an error when you consider the surrounding expressions to check if the property exists...