首页 文章

使用groovy脚本迭代soapuI中的测试步骤

提问于
浏览
1

我目前正在尝试为SoapUI中的测试套件生成报告 .

我的旧工作代码就是这一行,在testSuite拆解脚本中:

def testc = project.testSuites['TestSuite'].testCases['TestCase'].testSteps['xxxxx']

但是每次新的测试步骤都必须重复 .

我正在尝试使用的代码是这样的:

for (service in project.testSuites) {
    for (testCase in service.testCases) {
        for (testStep in testCase.testSteps) {
            someFile.withWriterAppend{out ->out.println testStep.toString()}
        }
    }
}

Wich正在给我这个错误:

groovy?lang.MissingPropertyException:没有这样的属性:类的testCases:javaUtil.hashMap $ Node

由于我使用相同的路径访问每个测试步骤,我很惊讶无法通过迭代来完成它 .

1 回答

  • 1

    project.testSuites 为您提供 Map . 因此错误 . 而是使用 project.testSuiteList 给出列表 . 所以,上述错误消失了 .

    同样,其他对象也是如此 . 请参阅下面更改的代码段 .

    for (suite in project.testSuiteList) {
        for (kase in suite.testCaseList) {
            for (step in kase.testStepList) {
                someFile.withWriterAppend{out ->out.println testStep.toString()}
            }
        }
    }
    

相关问题