Search code examples
jmeter-5.0jmespath

jmes path assertion failing in jmeter


In my jmeter test, the test receives the following json response.

{"result":"success","additional-info":"{\"external-profile\":{\"email\":\"myemail@gmail.com\",\"firstname\":\"fn\",\"lastname\":\"ln\",\"portfolio\":{\"tags-of-interest\":[],\"question-created-tags\":[{\"tag\":\"un2-new tag-empty\",\"count\":1},{\"tag\":\"un2-new tag2-empty\",\"count\":1}],\"question-answered-tags\":[]}}}"}

I want to check that the message has path additional-info.exernal-profile.portfolio and that there are keys tags-of-interest, question-created-tag,question-answered-tag

I am using json jmes path but I am getting error Assertion failure message:Invalid argument type calling "keys": expected object but was null

What am I doing wrong?

enter image description here


Solution

  • Just go for 2 JSON JMESPath Extractors:

    1. Extract the content of additional-info attribute into a JMeter Variable from the response

      enter image description here

    2. Extract the attributes from the external-profile attribute:

      enter image description here

    You can see the extracted values using Debug Sampler and View Results Tree listener combination:

    enter image description here


    Be aware that since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting as:

    More information: Apache Groovy - Why and How You Should Use It