如何停止 Beanshell 断言中程序的进一步执行

How to stop the further execution of a Program in Beanshell Assertion

if(!reqAdSize.equalsIgnoreCase(hm.get("ad_size")))
{
    Failure = true;
    FailureMessage = "Ad Sizes Doesn't Match";
}

if(!reqCur.equalsIgnoreCase(resCur))
{
    Failure = true;
    FailureMessage = "Request & Responce Currency are NOT same";
}

if(!reqID.equalsIgnoreCase(resID))
{
    Failure = true;
    FailureMessage = "Request & Responce Id is NOT same";
}

在我的jeMter中,如果条件满足,这里是我的BeanShell断言代码。 结果它将显示最后一个 FailureMessage。如果第一个条件为真并且它不会进一步执行,我需要停止执行代码。

我尝试使用 System.exit(0);exit();。但是 jMeter GUI 会自动关闭。
BeanShell在当前行停止执行的方法是什么

在您想停止执行 BeanShell 代码的任何地方添加 return 关键字。

您在 Beanshell 断言中有 SampleResult 预定义变量,它是 shorthand for org.apache.jmeter.samplers.SampleResult class。查看以下方法:

类似于:

if (!reqAdSize.equalsIgnoreCase(hm.get("ad_size"))) {
    Failure = true;
    FailureMessage = "Ad Sizes Doesn't Match";
    SampleResult.setStopTest(true);
}

JMeter 上下文中的 Beanshell 脚本指南:How to Use BeanShell: JMeter's Favorite Built-in Component