【问题标题】:getting name of previous test step in SoapUI groovy script在 SoapUI groovy 脚本中获取上一个测试步骤的名称
【发布时间】:2014-08-22 04:32:00
【问题描述】:

我是 SoapUI 中 groovy 脚本的新手,对可用信息量有点困惑,所以我可能只是忽略了这个问题的答案。

在加载 GroovyUtils 的脚本中有一个方法 context.getCurrentStep()。但是在脚本步骤中,这当然会返回脚本步骤本身的名称。

现在我想在不明确使用名称的情况下访问上一步的名称(更准确地说是响应)。有没有简单的方法来实现这一点?

【问题讨论】:

    标签: groovy automated-tests soapui


    【解决方案1】:

    你可以这样做:

    def currentStepInd = context.currentStepIndex
    def previousStep = testRunner.testCase.getTestStepAt(currentStepInd - 1)
    log.info previousStep.name
    

    更多信息请访问API JavaDocs

    【讨论】:

      【解决方案2】:

      您可能希望在脚本中执行以下操作:

      def response = context.expand( '${previous_step_name#Response#}' )
      

      【讨论】:

      • 您好,感谢您的回复,但是,不,我不想那样做。我想避免使用上一步的名称,这在我的问题中明确说明,这正是我的问题的重点。
      • 在实践中通过唯一名称引用步骤是更好的方法,这与我们引用函数的原因大致相同,我的名字,而不是行号。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-09
      • 1970-01-01
      相关资源
      最近更新 更多