Vladimir
Vladimir

Reputation: 658

JMeter - How to pass an array into a property variable?

I have a BeanShell PostProcessor under the setUp Thread Group.
It generates an ArrayList that I want to pass as a system property to the test Thread Groups in the Test Plan.
That array contains the number of threads in the test groups.
What is the syntax? How should I refer an element of that array in the Tread Group "Number of Threads (users)"?

This is what I have in the setUp Thread Group

ArrayList users = new ArrayList();
${__setProperty(users, ${users})};

This is what I put in the Number of Threads

${__P(users).get(0)}

It does not work.
Thanks enter image description here enter image description here

Upvotes: 0

Views: 7816

Answers (1)

Dmitri T
Dmitri T

Reputation: 168092

If you really need the "ArrayList" you can go it using bsh.shared namespace

  1. In setUp Thread Group put the ArrayList into the "bsh.shared" namespace like:

    ArrayList users = new ArrayList();
    users.add(5);
    bsh.shared.users=users;
    
  2. In normal Thread Group you can read the value via __BeanShell function as:

    ${__BeanShell(bsh.shared.users.get(0),)}
    

However I feel that your test is badly designed and you could get rid of scripting or at least of using arrays.

Upvotes: 1

Related Questions