uru917
uru917

Reputation: 91

JMeter share Regular Expression array variables between Thread Groups

In Thread Group #1 I have a Regular Expression with Match Number set to -1 and I want to use the complete variable in Thread Group #2.

I am currently able to share normal variables using props.put but I am not able to share the complete array to then obtain the values using __V function on Thread Group #2.

Is this feasible?

Upvotes: 0

Views: 441

Answers (1)

Dmitri T
Dmitri T

Reputation: 168157

Just add JSR223 PostProcessor (make sure it goes after Regular Expression Extractor) and use the following code:

vars.entrySet().each { var ->
    if (var.getKey().startsWith('foo')) {
        props.put(var.getKey(), var.getValue())
    }
}

In another Thread Group you can convert properties into variables using the same approach:

props.entrySet().each {prop ->
   if (prop.getKey().startsWith('foo')){
        vars.put(prop.getKey(),prop.getValue())
   }
}

Just replace foo with your variable reference name and that would be it.

You can find information regarding Groovy scripting in JMeter in Apache Groovy - Why and How You Should Use It guide if needed.

Upvotes: 0

Related Questions