'JMeter If Controller

not too sure if this is a user error but I can't seem to get this working. I have a test that returns 200 and this always hits the If controller, but the following fails.

I get a productID, if this is nested then i get the first one.
Regex is prodID "ProductId":(.*?), $1$ 0

Then as I want to use this in another thread group I cjhange to a property: ${__setProperty(prodID-${__threadNum},${prodID},)}

Then i use If Controller as ${__P(prodID-${__threadNum})} == "18"

Then it runs the same regex, but this time with $2$

Problem is that the If Controller isn't getting run on any, is there a way I can see this, or even is the above correct?

Thanks



Solution 1:[1]

The If Controller run its children if the expression evaluates to true

You're giving 18 == "18", it is not equal to true therefore the children are not getting executed.

I would suggest using __groovy() function instead like:

${__groovy(props.get('prodID-' + ctx.getThreadNum()).equals('18'),)}

where

See Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information on this and other JMeter API shorthands

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitri T