I have several JMeter test plans which should be executed in different environments, say Dev, Test, UAT, Live. In each test plan I would like to have a simple way to specify which environment to use. Each environment has a lot of configuration such as hostname, port, ssl-cert, user name, password, account numbers and other test data.
One thing I'm trying to achieve is the ease of switching environments while using JMeter GUI or running scenarios from build scripts.
One of my ideas is to use the "Include Controller" to include another jmx file which has list of User Defined Variables and other config elements. However, JMeter does not support variables in the included file name, so I cannot parametrise the scenario by an environment name. Include Controller supports JMeter parameter "includecontroller.prefix", but it is not very flexible, e.g. I cannot change it from JMeter GUI, I should change JMeter config files and restart it.
I've tried to use Switch Controller, but no luck, it doesn't switch configuration elements, only samplers.
What is the best practice to externalise environment specific configuration from test scenarios and share it between several scenarios?
If your are looking to make your life easy in the GUI only, an easy way is to duplicate your User Defined Variables for each environment and disable all others except the environment you are executing your tests against, something like the following:
I would suggest to substitute all environment-specific variables or values with JMeter Properties. See following functions for reference:
For example you can define a property called hostname
in either jmeter.properties file or as JMeter command line argument as follows
jmeter -Jhostname=169.140.130.120 -n -t yourscript.jmx -l yourscriptresults.jtl
and refer to in inside your script as:
${__P(hostname,)}
or${__property(hostname,,)}
See Apache JMeter Properties Customization Guide for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With