4

I am trying to do some performance testing on a REST service.I am using JMeter to do that.

As many REST services, my request service requires authorization token to be passed in Authorization header.

I want to have 5 threads which should use five different tokens to mimic five users.

I have a single Thread group with five threads. I've added HTTP Header Manager to add Authorization header.

How can I substitute each users auth token for each thread? If I use variable then threads uses same auth token.

Is there any better approach for this?

3 Answers 3

4

Given you have variables like:

token_1=sometoken
token_2=someothertoken
etc.

You can use __V() and __threadNum() functions combination so each thread could use different variable holding the token as follows:

${__V(token_${__threadNum})}

Demo:

Functions - threadnum + V

See How to Use JMeter Functions articles series for more information on above and other JMeter functions

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

Comments

1

Within Thread Groups, the User Parameters Pre-Processor can be used to set different parameters for each simulated user.

Here are tips how to do it

Comments

0

It is too late but I am suggested to use "User Parameters" in "Pre Processors" or "CSV Data Set Config" for inputting different variable.

User parameters allow to use martix to handle variable User parameters allow to use martix to handle variable

CSV Data Set Config allow to read variable from local csv file CSV Data Set Config allow to read variable from local csv file

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.