我有一组测试用例ReusableComponent test Suite。
我不能单独运行ReusableComponent。它没有session和othertuff。从其他套件调用时,它会将必要的数据传递给可重用的组件。
我们可以使用下面的闭包获得每个api调用响应时间吗?
testSuite = testRunner.testCase.testSuite.project.testSuites["ReusableComponent"]
//Loop thru each case of the suite and find those matching properties and clear them
testSuite.testCaseList.each { testcase ->
testcase.testStepList.each{testStepName ->
log.info(testStepName.name)
def props = testcase.testSteps["$testStepName"].testRequest.response.timeTaken
def msg = props ?: 'None'
log.info "Reponse Time for ${testStepName} test are : ${msg}"
}
}
我收到以下错误:
Can not get Property TestRequest on Null object.
此错误消息说,因为我没有运行此测试用例,它说。但不能单独运行ReusableComponent。有没有人在整个运行后得到时间,只需从ReusableComponent套件中获取时间
答案 0 :(得分:0)
以下声明将为您提供请求呼叫所需的时间。
log.info "Time taken : ${testRunner.timeTaken}"
如果在TearDown Script
的测试用例中使用,那么它将为测试用例提供执行时间。
如果是测试套件TearDown Script
,请使用log.info runner.timeTaken