-1

I have a question about variables, in groovy in jmeter. I want to create a test that in the first step read data via groovy sampler, and put it in variable budget, def = old_budget; and in the end of the test I want to create another sampler and check if budget is old_budget - 5.

In the parameters of the second sampler I put ${old_budget}, but the sampler not recognized the variable from the previous sampler, what I am missing?

P.S. the variable is not user defined variable it is defined in the first sampler

enter image description here

enter image description here

enter image description here

Bastian
  • 1,089
  • 7
  • 25
  • 74

1 Answers1

0

In order to create a new JMeter Variable called old_budget having the value of budget variable you can do it like:

vars.put('old_budget', vars.get('budget'))

Looking into your screenshots it seems you're misusing the Parameters feature,

  1. You need to separate variables you pass through "Parameters" section by spaces, not by commas
  2. You can refer them individually using args[] shorthand like:

    - `args[0]` - for "budget"
    - `args[1]` - for RedisIP
    - etc.
    

    Demo:

    Groovy accessing parameters

More information:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Hey Dimitry I try I think all the permutations to pass old_budget from sampler one to sampler 2 (new pic displayed). as you can see none of the worked, I tried to put values of old_budget into old_budget_test in the first sampler and it is not passed either, can you provide any example of sampler 1 and what should be in it, and sampler 2? – Bastian Oct 02 '17 at 07:21