JMeter-将断言结果另存为变量 [英] JMeter - save assertion results as a variable

查看:276
本文介绍了JMeter-将断言结果另存为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JMeter中,我有一个包含几个断言的自动化测试计划.在我的断言结果侦听器中,我可以在方便的概述中查看所有断言的结果.到目前为止一切顺利.

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.

在测试计划结束时,我打电话给JIRA,以发布测试结果的新版本.我希望该问题的描述包含断言结果侦听器的概述.

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.

如何将断言结果定义为变量,以便以后可以在JIRA调用中引用它们?

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

如何将该视图映射到变量?

我的JIRA呼叫应如下所示:

My JIRA call should look like this:

POST/rest/api/2/issue

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"
   }
}

推荐答案

您可以在Sampler之后添加以下断言:

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());

它将第一条断言消息保存在assertionresults变量中.

It will save in assertionresults variable the first assertion message.

这篇关于JMeter-将断言结果另存为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆