【问题标题】:Jmeter stop the current iteration issueJmeter停止当前迭代问题
【发布时间】:2020-05-28 09:48:52
【问题描述】:

如何使用 jmeter 停止当前迭代并使用 beanshell 脚本移动到下一个迭代。 (不使用测试动作元素)

我尝试了 ctx.setRestartNextLoop(true) 但这不起作用。

JMeter 版本:5.2.1

【问题讨论】:

    标签: jmeter jmeter-plugins jmeter-5.0 jmeter-4.0


    【解决方案1】:
    1. Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language 用于任何形式的脚本
    2. 如果出于某种原因(尽管我看不到任何正当理由),您仍想使用 JSR223 Sampler 而不是 Flow Control Action 采样器来执行此操作 - 相关代码将是:

      SampleResult.setIgnore()
      ctx.setTestLogicalAction(org.apache.jmeter.threads.JMeterContext.TestLogicalAction.START_NEXT_ITERATION_OF_CURRENT_LOOP)
      

    有关 JMeter 中 Groovy 脚本的更多信息:Apache Groovy - Why and How You Should Use It

    【讨论】:

    • 你能给我这个用​​例的 groovy lang 的代码 sn-p,以便我可以尝试相同的方法吗?我用以下代码尝试了 beanshell 断言,但它不起作用。导入 org.apache.jmeter.samplers.SampleResult;导入 org.apache.jmeter.threads.JMeterContext;导入 org.apache.jmeter.threads.JMeterContext.TestLogicalAction;导入java.io.*;字符串 s1= ${SampleValue}; if(s1.contains("Hello")) { SampleResult.setIgnore(); ctx.setTestLogicalAction(org.apache.jmeter.threads.JMeterContext.TestLogicalAction.START_NEXT_ITERATION_OF_CURRENT_LOOP); }
    • 有什么建议吗?
    • 我是否在任何地方提到过“Beanshell 断言”?我明确表示JSR223 Sampler,你should not be using Beanshell for anything since JMeter 3.1
    猜你喜欢
    • 2015-05-04
    • 1970-01-01
    • 2012-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多