ATLANTBH jmeter-components: JSON Path Assertion

跟風遠走 提交于 2019-12-05 07:07:35

Looks like you can easily assert both 1009 and SOME RANDOM MESSAGE values using JSONPath expressions (in JSON Path Assertion components) but not sure about 123456789: that's not node value but bode name, and JSONPath implementation used by these components seems has no expressions to get node name.

Suppose you can easily use to assert 123456789 instead binding of JSON Path Extractor (from the same components collection) with jmeter's standard Response_Assertion.

  1. Add 2 JSON Path Assertions as children to the sampler which returns json response you want to process:

    Expressions will be $.result.errors..code and $.result.errors..error correspondingly.

  2. Add JSON Path Extractor as child to the same sampler to extract full error entry:

    Expression: $.result.errors..
    This will extract {"123456789":{"error":"SOME RANDOM MESSAGE","code":1009}} and save into the pointed variable (${errorKey}).

  3. Add Response Assertion as child to the same sampler, after previously added JSON Path Extractor:

    This will assert name of the key (123456789) in the value of ${errorKey} variable.


So the final construction may look like

...
YOUR Sampler
    JSON Path Extractor
    JSON Path Assertion
    JSON Path Assertion
    Response Assertion
...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!