【问题标题】:Groovy Script and Property transfer in soapUIsoapUI 中的 Groovy 脚本和属性传输
【发布时间】:2016-02-19 04:44:14
【问题描述】:

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

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

  1. groovy 脚本
  2. soapUI 请求 (GetAccountNumber)
  3. 属性转移步骤(将响应属性从上方转移到以下步骤中的请求属性)
  4. soapUI 请求 (DownloadURL)

我需要确保流程如下:

  1. Groovy 运行并从文件中读取数字并将它们传递给 GetAccountNumber。
  2. GetAccountNumber 使用传递的值运行并生成响应。
  3. 此响应由属性传输步骤传递到 DownloadURL。
  4. 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)

【问题讨论】:

  • 在其他可以完成的情况下,属性转移步骤运行的问题是什么?
  • 它没有使用以下代码运行 - ` 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);`
  • @RikarnobBhattacharyya 我编辑了问题,添加了您在提交中添加的代码:)

标签: groovy soapui


【解决方案1】:

如果没有更多上下文,我认为你的问题是一个简单的错字,你得到你的 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 然后运行它更方便。

希望对你有帮助,

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-19
    • 2016-06-02
    • 2022-08-18
    相关资源
    最近更新 更多