gpt4 book ai didi

java - SoapUI 如何获取每个测试步骤的请求和响应大小

转载 作者:行者123 更新时间:2023-12-02 11:01:56 25 4
gpt4 key购买 nike

我有一些 Groovy 脚本,它循环当前测试用例中的测试步骤,并对每个步骤的响应时间求和,并将其存储在测试用例的自定义属性中。

我现在尝试对每个测试步骤的请求和响应大小执行相同的操作,但似乎无法使其工作。

def TestCase = testRunner.getTestCase()
def CurrentTestStep = context.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel()
def StepList = TestCase.getTestStepList().name - CurrentTestStep

def ResponseTime = 0
def RequestSize = 0
def ResponseSize = 0

StepList.each
{ Step ->
try
{
ResponseTime = ResponseTime + testRunner.testCase.testSteps[Step].testRequest.response.timeTaken
}
catch(Exception expObj)
{

}
}

testRunner.testCase.setPropertyValue("Test_Case_Response_Time", ResponseTime.toString())

最佳答案

您可以使用以下声明来了解响应大小。

 log.info "Size of " + Step  + "is " +  testRunner.testCase.testSteps[Step].testRequest.response.responseSize 

完整的代码是

def TestCase = testRunner.getTestCase()
def CurrentTestStep =
context.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel()
def StepList = TestCase.getTestStepList().name - CurrentTestStep
def ResponseTime = 0
def RequestSize = 0
def ResponseSize = 0

StepList.each
{
Step ->
try
{
log.info "Size of " + Step + "is " + testRunner.testCase.testSteps[Step].testRequest.response.responseSize

ResponseSize= ResponseSize + testRunner.testCase.testSteps[Step].testRequest.response.responseSize

}
catch(Exception e)
{
}
}

testRunner.testCase.setPropertyValue("Test_Case_Response_Size", ResponseSize.toString())

对于请求大小,我无法找到获取大小的语句。收到后会添加。

关于java - SoapUI 如何获取每个测试步骤的请求和响应大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51267637/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com