Solved

TBox Evaluation Tool not evaluating expression

  • 7 April 2024
  • 9 replies
  • 70 views

Badge

I am using TBox Evaluation tool with a business parameter. The  business parameter maybe empty or have a value. When the business parameter is empty, TBox Evaluation Tool seems to always execute as true, even though it doesn’t say whether it evaluated to true or false. 

icon

Best answer by brendon.russell 16 April 2024, 22:42

View original

9 replies

Userlevel 1

Thats the way Reusable Test Step Blocks work. If a step is using a Business Parameter, that step is executed only if a value is passed for that Business Parameter. If not value is passed then that step is not executed and just shows green. If you want a different outcome then you may have to redesign.

Userlevel 3
Badge +1

Thats the way Reusable Test Step Blocks work. If a step is using a Business Parameter, that step is executed only if a value is passed for that Business Parameter. If not value is passed then that step is not executed and just shows green. If you want a different outcome then you may have to redesign.

Indeed! Specifically @Enigma  it sounds like you will also need to put a condition on the TBox Evaluation step so it only executes if the business parameter is not null. Then you may also need to add a different step with the opposite condition (parameter = NULL), to do whatever it is you want to happen when the parameter is not passed in.

Badge

Hi, thanks for your replies. I understand the parameters not getting executed if the parameter has no value. What I don’t understand is why the TBox Evaluation Tool is grey when the parameter is empty and continues to execute the then block anyway as if it evaluated to true.

Also, how can I check for a parameter not being null, I tried != NULL but the Tbox Evaluation is just grey and just executed the then block anyway.

 

 
 

 

 

Userlevel 3
Badge +1

Hi, thanks for your replies. I understand the parameters not getting executed if the parameter has no value. What I don’t understand is why the TBox Evaluation Tool is grey when the parameter is empty and continues to execute the then block anyway as if it evaluated to true.

Also, how can I check for a parameter not being null, I tried != NULL but the Tbox Evaluation is just grey and just executed the then block anyway.

 

 
 

You nee

 

You’ll need to apply the !=NULL condition to the test step itself, not the value, so that the whole step either exists (with the parameter value) or not. If the TBox Evaluation Tool step exists with no Expression value at all, Tosca will just pass the step without doing anything.

Badge

Hi, tried that but unfortunately didn’t work. I think what you meant was putting the condition in the teststep using the condition column? Tried but didn’t work. Teststep always executes as long as the parameter value is null, regardless of using !=NULL condition. Tried variants such as != ‘NULL’ or even {NULL}.

Let me explain what I am seeking to do:

 

 

Basically what I want is to execute certain steps (which are in a folder) only if A or B have a value.I thought initially that it was as easy as using TBox valuation Tool and writing {PL[A]}==x || {PL[B]}==x so that execution only occurs when A or B have an x value but that didn’t work.

Userlevel 3
Badge +1

Hi, tried that but unfortunately didn’t work. I think what you meant was putting the condition in the teststep using the condition column? Tried but didn’t work. Teststep always executes as long as the parameter value is null, regardless of using !=NULL condition. Tried variants such as != ‘NULL’ or even {NULL}.

Let me explain what I am seeking to do:

 

 

Basically what I want is to execute certain steps (which are in a folder) only if A or B have a value.I thought initially that it was as easy as using TBox valuation Tool and writing {PL[A]}==x || {PL[B]}==x so that execution only occurs when A or B have an x value but that didn’t work.


OK, so yes conditions on the test step / folder / test step value are definitely the way to do this within a reusable test step block. You shouldn’t need to reinvent anything using TBox Evaluation Tool etc.

Here’s a real world example of a condition used on a test step folder. (Note the single quote marks around the parameter name/path are only required if there are spaces in it.)

Note that the easiest way to do this is just to drag and drop the parameter onto the test step or folder. Tosca should automatically add a != NULL condition using that parameter. You can modify the condition manually from there. If you drag a second parameter, it will even add this to the condition with an OR.
 


The screenshot you provided doesn’t have anything in the Condition column so it’s hard to say what else you might have missed.

Badge

Thank you! That has been helpful and is precisely what I was looking for in many ways. I thought of extending your helpful tip to check for non-null values, e.g. using your example, ‘Input.Order-Reason’ == ‘somevalue’ but Tosca just skips that. I have also tried using the parameter value, e.g. ‘{PL[Input.Order-Reason]}’ == ‘somevalue’ but it didn’t work.

Badge

With some further tests, it appears that with double quotes it works but only for one parameter. It seems Param1 = “somevalue” OR Param2 = “someothervalue” doesn’t work.

With Business Parameters there are a lot of issues to think of (AFAIAA):
1. Always use at least two comparators
2. Better put the params in single quotes
‘Param1’ == “somevalue” OR ‘Param2’ == “someothervalue”
3. instead of OR you can also use || (two vertical bars aka two pipe symbols) and instead of AND use && (two ampersand symbols)
4. you can use the same comparators as in TQL meaning =i= to compare case insensitive =~ to compare against regular expression
5. (and perhaps most important) it will NOT work if you use buffers as Business Parameters. Meaning if you have a Business Parameter someParam and fill it with value {B[somebuffer]} a condition like ‘someParam’ == “someValue” will ALWAYS fail. Because the condition compares {B[somebuffer]} and not the value of {B[somebuffer]} against ‘someParam’
Hope that helps.
Regards

Reply