JMeter assertion for a API response which contains [] or string "transaction"

How can we assert an API response which contains [] or "transaction"?

Jmeter Assertion should pass if it contains any of the below response
Response 1: [] (only empty square brackets)
or
Response 2: contains string "transaction" as part of response

>Solution :

The easiest is going for Response Assertion configured like:

enter image description here

It will pass in 2 cases:

  • when response body will contain []
  • or when response body will contain transaction

if response body won’t contain any of these – the assertion will fail.

More information: What Are JMeter Response Assertions?

Leave a Reply