JMeter - save assertion results as a variable

一世执手 提交于 2020-04-16 06:05:03

问题


In JMeter I have an automation test plan with several assertions. In my assertion result listener I can see the result off all assertions in a handy overview. So far so good.

At the end of the test plan, I'm calling JIRA to post a new issue with the test results. I want the description of that issue to contain the overview from the assertion result listener.

How can I define the assertion results as a variable, so that I can reference them later in my JIRA call?

How can I map this view to a variable?

My JIRA call should look like this:

POST /rest/api/2/issue

{
"fields": {
   "project":
   {
      "key": "Blah"
   },
   "assignee": {
      "name": "Joe"
    },
    "priority": {
      "name": "Major"
    },
   "summary": "Jmeter Test Result",
   "description": "${assertionresults}",
   "issuetype": {
      "name": "Test Execution"
   }
}

回答1:


You can add after the Sampler with the assertion:

Test Action and inside it a JSR223 PreProcessor and write the following code using AssertionResult.getFailureMessage method:

  vars.put("assertionresults", prev.getAssertionResults()[0].getFailureMessage());

It will save in assertionresults variable the first assertion message.



来源:https://stackoverflow.com/questions/51286630/jmeter-save-assertion-results-as-a-variable

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