0
votes

In JMeter, I have added a Config Element of User Defined Variables to state my variable data. However, I see I can do the same thing up in the main Test Plan element.

When should you define your variables within the Test Plan and when should you define them within the Config Element? What's the pro/con of each?

Thanks.

1

1 Answers

0
votes

They are the same. Take a look at User Defined Variables description:

The User Defined Variables element lets you define an initial set of variables, just as in the Test Plan

But using separate config elements makes sense for 2 reasons:

  • Script organization. For example if you have many variables, instead of dumping them all in main Test Plan element, you could define several config elements with the name that suggests what kind of variables they store.

  • Ability to use variables defined in previous User Defined Variables elements. According to the same reference:

    UDVs are processed in the order they appear in the Plan, from top to bottom. <...> the variables are not available for use until after the element has been processed, so you cannot reference variables that are defined in the same element. You can reference variables defined in earlier UDVs or on the Test Plan.

    So having several elements provides you with an ability to use previously defined variables in the further ones. One of the use cases is, for instance, definition of some reusable function(s) in one User Defined Variables element, and using them in the following User Defined Variables elements.