Groovy 将Soap请求的附件复制到TestStep请求中

Groovy 将Soap请求的附件复制到TestStep请求中,groovy,soapui,Groovy,Soapui,我正在用一个加载脚本(项目级)将项目的Soap请求复制到一个测试用例中,除非我发现没有复制所有附件文件,否则一切都很顺利 这是我的剧本: testsuite=project.addNewTestSuite("Suite") testcase=testsuite.addNewTestCase("Case") def iface= project.interfaces["Interface"] def op = iface.operations["Operation"] op.getReques

我正在用一个加载脚本(项目级)将项目的Soap请求复制到一个测试用例中,除非我发现没有复制所有附件文件,否则一切都很顺利

这是我的剧本:

testsuite=project.addNewTestSuite("Suite")
testcase=testsuite.addNewTestCase("Case")

def iface= project.interfaces["Interface"]
def op = iface.operations["Operation"]

op.getRequestList().each { req ->

   def config=com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory.createConfig(req,  req.getName())
   def newTestStep = testcase.addTestStep( config ); 
}
有没有办法将每个请求的附件复制到它的testStep副本中

如果我需要手动添加测试套件,并使用设置脚本(使用上下文、运行程序…),我已经准备好了


谢谢

您必须从操作列表中的请求中获取所有附件,并在新的测试步骤中导入每个附件,类似的内容必须适用于您的情况:

req.attachments.each{ attach ->
    newTestStep.testRequest.importAttachment(attach)
}
在您的代码中:

def project = testRunner.testCase.testSuite.project
def testsuite= project.addNewTestSuite("Suite")
def testcase= testsuite.addNewTestCase("Case")

def iface= project.interfaces["Interface"]
def op = iface.operations["Operation"]

op.getRequestList().each { req ->
  def config=com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory.createConfig(req,  req.getName())
  def newTestStep = testcase.addTestStep( config )

  req.attachments.each{ attach ->
    newTestStep.testRequest.importAttachment(attach)
  }
}

您必须从操作列表中的请求中获取所有附件,并在新的TestStep中导入每个附件,类似的内容必须适用于您的情况:

req.attachments.each{ attach ->
    newTestStep.testRequest.importAttachment(attach)
}
在您的代码中:

def project = testRunner.testCase.testSuite.project
def testsuite= project.addNewTestSuite("Suite")
def testcase= testsuite.addNewTestCase("Case")

def iface= project.interfaces["Interface"]
def op = iface.operations["Operation"]

op.getRequestList().each { req ->
  def config=com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory.createConfig(req,  req.getName())
  def newTestStep = testcase.addTestStep( config )

  req.attachments.each{ attach ->
    newTestStep.testRequest.importAttachment(attach)
  }
}

哦,我迟到了。。。无论如何,谢谢你的反馈:)哦,那我就迟到了。。。谢谢你的反馈:)