1

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.

1 Answer 1

3

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:

  1. First Thread Group:

    int abc=10   
    int start=abc+1
    props.put('id', start)
    
  2. 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

1
  • @Dmitri T I have noticed, that the only way to transfer props from one Thread group to another is to explicitly read it from the props in the second thread grop and put, for example, explicitly to the vars; using the property name in the template will not work.
    – Eljah
    Sep 21, 2018 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.