Issue
I wrote a Jmeter Test that contains a While-Controller. The Test looks somewhat like this:
> Testlan
>> VARS
>> Thread
>>> HTTP Request
>>> Transaction Controller
>>>> User Parameters
>>>> HTTP Request
>> Result Tree
>> Test Fragment
>>> Transaction Controller
>>>> Init Loop Beanshell
>>>> Loop with Condition
>>>>> BeanShell Assertion
In "Init Loop Beanshell" I do this: vars.put("MyVar","okay");
So my While-Condition looks kinda like this: ${__javaScript("${MyVar}"!="stop")}
In my Assertion, there is a point where I do this: vars.put("MyVar", "stop");
The strange thing is, that in JMeter it works just fine and the loop is quit when the condition is false. In JUnit its just an endless loop. I already checked the vars in the JUnit log and MyVar is "stop" but it just doesn't quit the loop.
The log says: Condition value: false
I already wasted to much hours on figuring out why this wont work. I just want that the test quits the loop when i call it from JUnit as it is when i call it from JMeter.
Solution
So, if anyone cares, i solved it with a workaround. All those ${__javaScript/groovy/...(CONDITION)} did not work and i still don't know why.
But what worked in both jMeter and jUnit was to set the While-Condition on ${MyVar}
, initialize it with vars.put("MyVar","true");
and "clean" it on the Assertion with vars.put("MyVar", "false");
Answered By - dinkelbrot