Reputation: 65
In 1st Thread group, in bean-shell Post processor I have added following code to set Jmeter Property with name "id":
int abc=10
int start=${abc}+1;
${__setProperty("id",start)};
print(props.get("id"));
In Second thread group, I am trying to access the value of "id" in beanshell using:
int pq=${__P("id",1)};
Now, The value of 'pq' should be 11 but it takes default value which is '1'. When I check in Debug PostProcessor, the value of id is string 'start' and not 11. I am not sure what changes are required. One more interesting thing I noticed is: in console it prints 11 for "print(props.get("id"))" where as in jmeter property it stores the string value 'start'.
Any help is appreciated.
Upvotes: 1
Views: 1078
Reputation: 168042
First of all, usual notice, don't inline variables and function calls into scripting-based test elements as they may misbehave.
So you should amend your code like:
First Thread Group:
int abc=10
int start=abc+1
props.put('id', start)
Second Thread Group
int pq = props.get('id')
log.info('Property value: ' + pq)
NB: The above code assumes using of JSR223 Test Elements and Groovy language
Upvotes: 3