jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Schumacher <>
Subject Re: Need help on on Groovy or condition
Date Tue, 07 May 2019 12:36:42 GMT

Am 06.05.19 um 12:58 schrieb Niraj:
> Hi,
> Can someone please tell me what is wrong in below code? I am trying to
> verify if testName is not equal to test 1 or test 2. Both expressions are
> not working.
> ${__groovy(!vars.get('testName').contains("test1"))} ||
> ${__groovy(!vars.get('testName').contains("test2"),)}
> ${__groovy(!vars.get('testName').contains(" test1 ")||(" test2 ),)}

Here are some pointers, why the code fragments don't work as expected:

* vars.get('testName') will give you a String. Strings don't have a 
contain method, so "vars.get('name').contains('something')" will not work.

* (" test2 ) is not a valid groovy expression and therefore will not work.

Now to get something meaningful. I assume, that you want to do an exact 
match on the var 'testName'. Then one possibility would be to use a List 
which has a contains method. That could be expressed as

${__groovy(!['test1'\, 'test2'].contains(vars.get('testName')))}

Note the backslash before the comma. It is needed to distinguish between 
a comma inside the groovy expression and a parameter for the JMeter 
groovy function.



> Thanks in advance,
> Niraj

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message