是否可以为线程组设置超时?

时间:2017-02-03 13:43:47

标签: jmeter

我有一个线程组,其中包含很少的HTTP请求。我将运行几百或几千个线程。我想设置线程组的超时,因此它超过给定时间时会超时。 有没有办法做到这一点?

3 个答案:

答案 0 :(得分:1)

当你说ThreadGroup的超时时 - 你的意思是测试的持续时间?也就是说,你想要测试特定的持续时间?如果是,您可以在线程组配置中设置持续时间。

enter image description here

如果您的意思是,单个HTTP请求采样器在特定持续时间后超时,那么{{1}}是设置它的最佳位置。

您也可以在特定的采样器中覆盖它。

enter image description here

答案 1 :(得分:0)

您可以使用JSR223 Assertion执行此操作,例如:

  1. 在测试计划中的某处添加JSR223断言(确保它不会经常执行)
  2. 在"脚本"中使用以下代码area(示例代码将使当前采样器失败并在线程组持续时间超过5秒时停止测试):

    def testStart = Long.parseLong(vars.get("TESTSTART.MS"))
    def now = System.currentTimeMillis()
    
    if ((now - testStart) >= 5000) {
        AssertionResult.setFailure(true)
        AssertionResult.setFailureMessage("Thread group duration exceeded 5000 ms")
        SampleResult.setStopTest(true)
    }
    
  3. 演示:

    JSR223 Assertion Example

    有关如何为JMeter测试设置通过/失败标准的详细说明,请参阅How to Use JMeter Assertions in Three Easy Steps文章。

答案 2 :(得分:-1)

在采样器enter image description here

中设置响应超时值
相关问题