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

Copy attachement of a Soap Request into TestStep request

我正在使用加载脚本(项目级别)将项目的 Soap Request 复制到测试用例中,一切顺利,除非我发现所有附件文件都没有被复制。

这是我的脚本:

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 副本中?

如果我需要手动添加我的测试套件,并使用设置脚本(使用上下文、运行程序...)我准备好这样做了。

谢谢

您必须从您的操作列表中的请求中获取所有附件,并在新的 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)
  }
}