0

I'm working with a JMeter test script where I need to use some pre-defined values (such as client_id, client_secret, scope, etc.) different for each request, that change depending on the environment (dev, QA, staging, prod).

Currently, these values are hardcoded into the script, which means every time I switch environments, I have to manually update the script — which is error-prone and not scalable.

What I’m looking for: A clean, maintainable way to make my JMeter script environment-agnostic so I can run it in any environment just by changing a config file or parameter — without editing the .jmx script itself.

Example Use Case:
For dev, I might use:
client_id = dev-client-id
scope 1  =  abc
scope 2  = def
...etc

For prod:
client_id = prod-client-id
scope 1  =  xyz
scope 2  =  vwx
like 50 of them
...etc

1 Answer 1

1

I can think of the following options:

  1. Put these values into different .properties file like for dev it will be dev.properties, for QA - qa.properties, etc.

    Once done you will be able to replace hardcoded values with __P() function calls. And when you will need to run a test against different environment you just feed the relevant .properties file to JMeter via -q command-line argument like:

    jmeter -q dev.properties -n -t test.jmx ....
    

    More information: Apache JMeter Properties Customization Guide

  2. Alternatively you can define properties with prefixes somewhere in User Defined Variables like dev_client_id, qa_client_id, etc. and then specify this "prefix" in another User Defined Variables

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

1 Comment

Thanks Ivan its working fine for me. Adding that if this need to be run in GUI then Jmeter need to be run with this command jmeter -q dev.properties instead of opening it directly

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.