Search code examples
performancejmeter

jmeter: Re-using same user defined variables in multiple test plans


I am trying to separate the code I have created in JMeter into individual test plans (.jmx files).

And it's visible that some values I am passing to header managers are common for all test plans. (For example, graphql fragments). If I just copy these static blocks from one file to another, it would introduce a need to edit things in multiple places, and Ideally, I want to define all variables in one place instead. What would be a good way for me to do it?


Solution

  • Normally when you want to "separate the code" you should go for Test Fragments and

    • either Include Controllers if you're using individual .jmx test scripts
    • or Module Controllers when you want to reuse a component or a group of components within the bounds of a single .jmx test plan.

    So if you save your User Defined Variables as a Test Fragment and reference it in your multiple .jmx test scripts any change to the variables will be automatically propagated to the test plans which reference the Test Fragment using Include Controllers.