问题
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