首页 文章

soapUI中的Groovy脚本和属性传输

提问于
浏览
0

有什么方法可以从 groovy script 运行 Property Transfer 步骤吗?两者都在同一个测试案例中 .

测试用例包含以下测试步骤:

  • groovy脚本

  • soapUI请求(GetAccountNumber)

  • 属性转移步骤(在以下步骤中将响应属性从上方传输到请求属性)

  • soapUI请求(DownloadURL)

我需要确保流程如下:

  • Groovy运行并从文件中读取数字并将它们传递给GetAccountNumber .

  • GetAccountNumber使用传递的值运行并生成响应 .

  • 此响应由属性转移步骤传递给DownloadURL .

  • DownloadURL以此传递的值运行并生成输出 .

我需要做的就是从groovy运行Property Transfer,因为其他步骤可以从groovy运行 .

它没有使用以下代码运行

def testStep_1 = testRunner.testCase.getTestStepByName("PropertyTransfer") 
def tCase_1 = testRunner.testCase.testSuite.testCases["SubmitGenerateReport"] 
def tStep_1 = tCase.testSteps["PropertyTransfer"] 
tStep_1.run(testRunner, context)

1 回答

  • 4

    没有更多的上下文我认为你的问题是一个简单的错字,你得到你的testCase并协助 tCase_1

    def tCase_1 = testRunner.testCase.testSuite.testCases["SubmitGenerateReport"];
    

    然而,为了获得 tStep_1 ,您使用 tCase 而不是 tCase_1

    def tStep_1 = tCase.testSteps["PropertyTransfer"]; tStep_1.run(testRunner, context);
    

    另外,如果你想从groovy运行的 testStep 与你正在执行的 testCase 相同;您只需使用以下命令即可运行:

    testRunner.runTestStepByName('some teststep name')

    我认为这比从 testCase 获取 testStep 然后运行它更方便 .

    希望能帮助到你,

相关问题