soap - 在 SoapUI 中使用 groovy 脚本记录测试步骤响应

标签 soap groovy soapui

我目前有一个测试套件,其中包含 76 个 Soap 测试步骤,所有步骤均已运行。但是在日志中,我按预期获得了测试步骤名称,但没有响应。

groovy 脚本和测试步骤都位于同一测试套件中,但测试用例不同。它具有以下结构:

  • 测试套件

    • 测试用例响应
      • 测试步骤
    • 测试用例日志
      • Groovy 脚本

Groovy 脚本:

def testCases = context.testCase.testSuite.getTestCaseList()
testCases.each
{

    for(testSteps in it.testStepList)
    {
        log.info "~~~Test Step:" + testSteps.name
        def requestname = testSteps.name
        log.info context.expand('${'+requestname+'#Response}')
    }
}

日志:

Tue Mar 21 11:50:04 GMT 2017:INFO:~~~Test Step:TestStep_0001
Tue Mar 21 11:50:04 GMT 2017:INFO:
Tue Mar 21 11:50:04 GMT 2017:INFO:~~~Test Step:TestStep_0002
Tue Mar 21 11:50:04 GMT 2017:INFO:
Tue Mar 21 11:50:04 GMT 2017:INFO:~~~Test Step:TestStep_0003
Tue Mar 21 11:50:04 GMT 2017:INFO:

为什么我没有获得每个测试步骤的响应中的数据?

最佳答案

这是Groovy Script,它可以满足您的需求: 关键是使用 step.getPropertyValue('Response')

import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep
//Repeat thru test cases
context.testCase.testSuite.testCaseList.each { tc ->
    tc.testStepList.each { step ->
        log.info "~~~Test Step:" + step.name 
        if (step instanceof WsdlTestRequestStep) {
            log.info step.getPropertyValue('Response')  
        } else {
            log.info 'Ignoring step as it is not SOAP request type step'
        }
    }
}

关于soap - 在 SoapUI 中使用 groovy 脚本记录测试步骤响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42926378/

相关文章:

ssl - 如何使用非自签名证书 X509 为 SSL 配置 SoapUI 模拟服务

xml - namespace URI 中尾部斜线的意义是什么?

Groovy:是否有命令行 REPL?

reflection - 打印出 Groovy 对象中的变量和值

testing - 我们如何在 SoapUI Pro 中使用 Groovy Script TestStep 将数组传递给方法?

java - 服务器返回 HTTP 响应代码 : 405 for URL

java - Spring配置两个@Endpoint,每个都有一个唯一的wsdl文件

php - 如何使用 PHP-curl 发送对 "multipart/related"Content-Type 的请求?

.net - 读取 MTOM 数据时已超出最大缓冲区大小

jenkins - 如何将作业放入jenkins的文件夹中?