如何在断言失败时终止 Jmeter script/test 的执行 - (GUI 运行)
How to terminate the execution of Jmeter script/test when assertion is failed - (GUI run)
我有断言 JSR223 断言 采样器,代码如下:
import groovy.json.JsonSlurper;
import com.fasterxml.jackson.databind.ObjectMapper;
JsonSlurper JSON = new JsonSlurper ();
ObjectMapper mapper = new ObjectMapper();
def jsonResponse = JSON.parseText(prev.getResponseDataAsString());
def hasError = jsonResponse.hasError
if (hasError) {
AssertionResult.setFailure(true);
}
如何在断言采样器内部根据 vars.get("JMeterThread.last_sample_ok")
变量停止断言采样器的执行,而不向脚本添加额外的元素?
你必须在断言后使用 If Controller
和 Flow Control Action
或
您可以使用 JSR223 Assertion
中的 ctx 变量来访问 JMeter 引擎以停止测试
查看详情here
感谢 Rahul Jadhav 的努力。
然而对我来说亲爱的是:prev.setStopTest(true);
或者使用断言采样器停止脚本的完整代码是:
if (hasError) {
AssertionResult.setFailure(true);
prev.setStopTest(true);
}
我有断言 JSR223 断言 采样器,代码如下:
import groovy.json.JsonSlurper;
import com.fasterxml.jackson.databind.ObjectMapper;
JsonSlurper JSON = new JsonSlurper ();
ObjectMapper mapper = new ObjectMapper();
def jsonResponse = JSON.parseText(prev.getResponseDataAsString());
def hasError = jsonResponse.hasError
if (hasError) {
AssertionResult.setFailure(true);
}
如何在断言采样器内部根据 vars.get("JMeterThread.last_sample_ok")
变量停止断言采样器的执行,而不向脚本添加额外的元素?
你必须在断言后使用 If Controller
和 Flow Control Action
或
您可以使用 JSR223 Assertion
中的 ctx 变量来访问 JMeter 引擎以停止测试
查看详情here
感谢 Rahul Jadhav 的努力。
然而对我来说亲爱的是:prev.setStopTest(true);
或者使用断言采样器停止脚本的完整代码是:
if (hasError) {
AssertionResult.setFailure(true);
prev.setStopTest(true);
}