Bastian
Bastian

Reputation: 1237

Compare User Defined Variable to Jmeter Variable Response

I have a question about user defined variable that I want to compare to field in Response:

  1. I created Json Extractor and put the value from the response that I need to check in a variable called CID.

  2. I have a user defined variable in the start of the test called Expected_CID

  3. I Added response Assertion
    In the response assertion I could find out how to compare CID to Expected_CID If I put the number it is working as expected but I want to use variable and not hard coded numbers.

Can someone please explain what I do wrong?

enter image description here enter image description here

Upvotes: 2

Views: 1897

Answers (2)

Ori Marko
Ori Marko

Reputation: 58882

To check variable in Response Assertion you need to put variable name inside ${}, this way JMeter will know you want to check your variable value.

In your case use ${Expected_CID} in Patterns to Test Text area, If not working make sure you don't have extra spaces in its User Defined Variables Value.

Notice in Response Assertion's Jmeter Variable you don't need to put variable name inside ${}, because it's expected for find variable.

A @UBIK LOAD PACK mention, notice that:

Variable names are case sensitive

.

Upvotes: 1

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34566

Variable names are case sensitive.

So for example , if you called CID, then cid won't match.

So in Response Assertion:

  • JMeter Variable : CID
  • In Patterns to test, use ${Expected_CID}

Upvotes: 2

Related Questions