hikarthiks
hikarthiks

Reputation: 47

Jmeter - Assert the response for a single parameter with set of values from array

Is there any way to validate whether a specific value is returned within the entire response which we get from Postman tool and set pass/fail conditions. for eg., my URL will be like https://www.testdomain.com/login?memberedu=123 and the specific value I am expecting in the response should be containing any of the following values ie.,'value1', 'value2', or 'value3' and if anything else returned for that parameter then it should fail. I am trying this in parallel with Postman tool also but so far couldn't figure out a proper way to get this validated. Sample Image

Here, I am trying to validate education value. Thanks in advance.

Upvotes: 0

Views: 300

Answers (1)

Dmitri T
Dmitri T

Reputation: 167992

  1. Add JSON Assertion (available since JMeter 4.0) as a child of the request which returns the above JSON
  2. Configure it as follows:

    enter image description here

  3. That's it, JMeter will automatically extract the EDUCATIONCATEGORY attribute value and check whether it is equal to M.S. (Engg.). If there will be a mismatch - JMeter will mark the parent sampler as failed and report the difference:

    enter image description here

Check out JsonPath Getting Started article to lean more about implementing correlation/pass fail criteria for JSON data in JMeter tests.

Also going forward please avoid posting code as image

Upvotes: 1

Related Questions