kcsurapaneni
kcsurapaneni

Reputation: 842

How to share the Integer type of value in jMeter

I wrote a Script in Test Case inside BeanShell PreProcessor and I want to use the value(Integer) in ThreadGroup.

By using vars.put() we can only share String type of values.

NOTE: I want to use the value in Number of Threads(users) block

Image Link

Upvotes: 0

Views: 3127

Answers (1)

Dmitri T
Dmitri T

Reputation: 168217

There are at least 3 ways of doing this:

  1. Use vars.putObject() - places an arbitrary Object into JMeterVariables
  2. Cast Integer to String vars.put("foo", String.valueOf(bar));
  3. Use bsh.shared namespace like:

    bsh.shared.myInt = 15
    

See How to Use BeanShell: JMeter's Favorite Built-in Component guide for more information on Beanshell scripting in JMeter tests

NOTE! you won't be able to amend number of threads in the current Thead Group using Beanshell test elements.

Upvotes: 1

Related Questions