使用 Groovy 脚本循环遍历 SOAP UI 中的所有测试用例和测试步骤
Loop through all test cases and test steps in SOAP UI using Groovy Script
作为测试套件拆解过程的一部分,我想遍历之前 运行 的所有测试用例和测试步骤,并捕获结果和断言。我不太擅长 groovy 脚本,这似乎很简单,但到目前为止进展不顺利。这主要是我对对象模型不熟悉,没有"intellisense"指导。我只需要 shell 作为开始。
另外,我有一个循环多次执行相同的测试步骤,输入不同的数据集。我不确定这是否有所作为。
这是我的 shell:
def testCases = context.testCase.testSuite.getTestCaseList()
testCases.each
{
log.info "~~~Test Case:" + it.name
for(testSteps in it.testStepList)
{
log.info "~~~Test Step:" + testSteps.name
}
}
但是我收到这个错误...
Wed Nov 04 15:53:44 EST 2015:ERROR:An error occurred [Cannot get property 'testSuite' on null object], see error log for details
如果您在测试套件的 TearDown 脚本 中使用它,那么下面的代码片段可以帮助您
testSuite.testCaseList.each {
log.info "Test Case : ${it.name}"
it.testStepList.each {
log.info "Test Step : ${it.name}"
}
}
请注意,测试套件的拆卸脚本可以使用以下变量,这些变量也可以在 soapUI 中注意到
log, context, runner, testSuite
您可以在此 上看到您正在努力实现的目标,以获得运行的测试套件的所有结果。
关于你的错误:
Wed Nov 04 15:53:44 EST 2015:ERROR:An error occurred [Cannot get property 'testSuite' on null object], see error log for details
问题是,如果您直接使用 tearDown script
中的播放按钮测试 tearDown script
单独执行(在 testSuite 之外),则会缺少一些变量,在本例中 context.testCase 为空,这就是您收到此错误消息的原因。此变量仅在执行整个测试套件时可用。
希望对您有所帮助,
作为测试套件拆解过程的一部分,我想遍历之前 运行 的所有测试用例和测试步骤,并捕获结果和断言。我不太擅长 groovy 脚本,这似乎很简单,但到目前为止进展不顺利。这主要是我对对象模型不熟悉,没有"intellisense"指导。我只需要 shell 作为开始。
另外,我有一个循环多次执行相同的测试步骤,输入不同的数据集。我不确定这是否有所作为。
这是我的 shell:
def testCases = context.testCase.testSuite.getTestCaseList()
testCases.each
{
log.info "~~~Test Case:" + it.name
for(testSteps in it.testStepList)
{
log.info "~~~Test Step:" + testSteps.name
}
}
但是我收到这个错误...
Wed Nov 04 15:53:44 EST 2015:ERROR:An error occurred [Cannot get property 'testSuite' on null object], see error log for details
如果您在测试套件的 TearDown 脚本 中使用它,那么下面的代码片段可以帮助您
testSuite.testCaseList.each {
log.info "Test Case : ${it.name}"
it.testStepList.each {
log.info "Test Step : ${it.name}"
}
}
请注意,测试套件的拆卸脚本可以使用以下变量,这些变量也可以在 soapUI 中注意到
log, context, runner, testSuite
您可以在此
关于你的错误:
Wed Nov 04 15:53:44 EST 2015:ERROR:An error occurred [Cannot get property 'testSuite' on null object], see error log for details
问题是,如果您直接使用 tearDown script
中的播放按钮测试 tearDown script
单独执行(在 testSuite 之外),则会缺少一些变量,在本例中 context.testCase 为空,这就是您收到此错误消息的原因。此变量仅在执行整个测试套件时可用。
希望对您有所帮助,