“IF” Parameter

WHAT IF? Thought you would never ask. This is very simple. Here is an example you can use

START: Create a Property file with a Name “value”

1. Lets Start with IF values equal the what you want it to equal

//Use the right-click GET DATA and point to the "value" name of the property step
def value = context.expand( '${Properties#value}' )

if (value == “one”)
“It’s All Good!!!”

RESULT: When you run this it will simply result in “It’s All Good!!!” or whatever you type in the quote.

———————————————————————————————————————————————————————————————————–

2. Now lets add in the “else” which is good use for when a value should reflect a static value, For example you always expect “one” but some reason you Test Step (API) send something else.
So in our example above we are only working with “one” – – Sooo what if the value was “three” or even a fault?

def value = context.expand( '${Properties#value}' )

if (value == “one”)
“It’s All Good!!!”
else
“I Don’t Know This Number Fool!”

RESULT: Still will show “It’s All Good!!!” if you didn’t change your property value. Change it to whatever you want and the result will now be “I Don’t Know This Number Fool!” < or again whatever you type.

———————————————————————————————————————————————————————————————————–

3. Now lets add more values since normally we expect more than a few values.
Here we’ll use the OR parameter which are two pipes ||

def value = context.expand( '${Properties#value}' )

if (value == “one” || value == “two”)
“It’s All Good!!!”
else
“I Don’t Know This Number Fool!”

RESULT: If you change the value to “one” or “two” the result is Good – – whereas anything ‘else’ will show the else result