首页 > 解决方案 > 对端点进行压力测试

问题描述

我是肥皂界面的新手。我的目标是使用soapui对端点进行压力测试。

我必须发出 1000 次发布请求并在 json 中增加我的 id 值

{
  "Id": ${valueToIncrement}
}

你能提供一些信息来实现我的目标吗?

标签: javajsonrestsoapui

解决方案


这应该为您解决问题:

import org.json.JSONObject;

def testStep = context.testCase.getTestStepByName("TestStep");

for (int i = 0; i < 10; i++) {
    final String json = testStep.getPropertyValue("Request");

    final JSONObject obj = new JSONObject(json);
    obj.put("Id", i);

    testStep.setPropertyValue("Request", obj.toString());
    testRunner.runTestStepByName(testStep.getName());
}

推荐阅读