'JMeter using a variable as input for a response assertion pattern

I have a test plan in JMeter that has a Response Assertion where I'd like to use a variable that comes from a CSV Data Set Config. So my Pattern looks like:

${assert1}

Which corresponds (at least in my thoughts) to what comes from the file used in CSV Data Set Config, but it doesn't work. I have seen multiple suggestions to use a Regular Expression Extractor, but the examples I saw refer to something they're trying to capture from a page. In my case I am using an external csv file.

My question: how can I use a variable as input for a Response Assertion pattern ?



Solution 1:[1]

I have successfully used a CSV Data Set Config as a source of string that I use in a url parameter, and then use a Response Assertion to seek out that parameter in the response.

  • Variable name: P.
  • URL: /product/${P}.
  • The response assertion Parterns to Test: ${P}.

I wonder if it is not necessary to use the CSV data variable in the request in order for it to be available in the response assertion?

Solution 2:[2]

If my understanding is right,
here your problem:
You want to use the value from your CSV as part of URL and that too via variable.

Solution:

Configure your CSV Data Set Config like this:

  • Filename: url csv path
  • variable name : assert1
  • Delimiter : , (if your CSV comma separated)
  • leave remaining unchanged

That's it you can use the variable assert1 anywhere: ${assert1}.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aliaksandr Belik
Solution 2 Aliaksandr Belik