2

I have the following Setup:

| Thread Group
| -- BeanShell PreProcessor
| -- Loop Controller

In The BeanShell PreProcessor I have:

vars.put("myDynamicNumber", someDynamicallyGeneratedNumber+"");

In The Loop Controller I have:

Loop Count: ${myDynamicNumber}

I was under the impression this would work. Instead the Loop Controller cannot find the variable. Am I doing something incorrectly?

2
  • 1
    It looks like I solved it by switching from BeanShell PreProcessor to BeanShell Sampler Commented Dec 18, 2013 at 13:25
  • 1
    ...As well it looks like any PreProcessor component should be added as CHILD to the control BEFORE which one you would like to execute processing. Commented Dec 18, 2013 at 17:09

1 Answer 1

2

You need to use Beanshell Sampler, not Beanshell Pre-Processor.

I don't know why does JMeter allow putting Beanshell Pre-Processor at the same level as loop controller, it should go as a child of i.e. HTTP Request.

I'd also suggest to slightly change your code to be:

vars.put("myDynamicNumber", String.valueOf(someDynamicallyGeneratedNumber));

Which is more correct from Beanshell perspective.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.