0

I’m working on a JMeter test plan where I need to control flow based on the result of a JSON extraction. Here’s the flow in my thread group: • Get Shelves (HTTP Request) • Inside it, I have a JSON Extractor that extracts the variable shelf__matchNr • A Debug Sampler placed immediately after confirms that shelf__matchNr = 0 • Then I have an If Controller with this condition:

${__groovy(
    def val = vars.get("shelf__matchNr");
    log.info(":test_tube: shelf__matchNr is: " + val);
    return val != null && val.toInteger() == 0;
)}

The problem: • Even though the Debug Sampler clearly shows shelf__matchNr = 0 • The log printed inside the If Controller shows null • The flow under the If Controller is not executed

I have Ensured that the JSON Extractor is correctly scoped inside the HTTP Sampler (Get Shelves) I have Ensured that the If Controller comes after the HTTP request and the extractor Use a Debug Sampler or log output to confirm variable values before the If Controller enter image description here

2 Answers 2

0

Your condition works perfectly when shelf__matchNr value is 0

Probably you have a PostProcessor which is applied to the Debug Sampler and it overwrites the value of the shelf__matchNr variable. Most probably if you disable the Debug Sampler the thread(s) will start entering the If Controller and executing its children See JMeter Scoping Rules for more information.

You can also enable JMeter debug logging, it will allow you to see when this or that variable is getting modified and what was the cause.

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you for the response , i added an image of the test plan log, disabled Debug Sampler still the same , Log are enabled and in log shelf__matchNr shows null , but when i enable Debug Sampler it shows shelf__matchNr = 0
what is JSR223 Listener doing?
that is placed for different purpose , it has code to append date to a variable that is passed in create device http request
Could you please a minimal reproducible example with i.e. Dummy Samplers demonstrating the issue, as I've mentioned the condition works fine given the variable is set, some test element either amends or removes it somehow.
the issue is resolved thanks :)
0
${__groovy(
    def val = vars.get("shelf_matchNr");
    log.info(":test_tube: shelf_matchNr is: " + val);
    return val != null && val.toInteger() == 0;
)}

This worked for me.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.