4

我有一堆 XML 格式的 SOAP 请求消息。有没有办法将它们导入 SoapUI 项目?

我想导入它们并作为“测试请求”测试步骤添加到现有的测试用例中。

4

4 回答 4

4

一种简单且更自动化的方法是使用 groovy 脚本从您拥有 xml 请求文件的目录中自动创建 testStep 请求:

  1. 手动创建一个测试用例。
  2. 添加一个空的 TestStep 请求,我们将使用它作为模板来创建其他请求。
  3. 添加一个 groovy testStep,它使用下面的代码导入所有文件,并执行它以创建 testSteps。

常规代码执行之前的 SOAPUI 如下所示:

在此处输入图像描述

以及必要的常规代码:

import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory
import groovy.io.FileType

// get the current testCase to add testSteps later
def tc = testRunner.testCase
// get the testStep as template to create the other requests
def tsTemplate = tc.getTestStepByName("TestRequest template")
// create the factory to create testSteps
def testStepFactory = new WsdlTestRequestStepFactory()

def requestDir = new File("/your_xml_request_directory/")
// for each xml file in the directory
requestDir.eachFileRecurse (FileType.FILES) { file ->
  def newTestStepName = file.getName()
  // create the config
  def testStepConfig = testStepFactory.createConfig( tsTemplate.getOperation(), newTestStepName )
  // add the new testStep to current testCase
  def newTestStep = tc.insertTestStep( testStepConfig, -1 )
  // set the request which just create with the file content
  newTestStep.getTestRequest().setRequestContent(file.getText())
}

希望这可以帮助,

于 2014-10-13T08:14:54.990 回答
1

Another option is:

  1. Create a soapui project with one request
  2. Open the soapui-project XML file
  3. Search for con:call part
  4. Duplicate it and replace the con:request with your own XML request
  5. Save and reload the project in soapui
于 2014-10-11T03:48:50.387 回答
1

或者在请求视图中打开上下文菜单时选择“从...加载”。

于 2010-10-19T19:58:27.577 回答
1

将每个请求复制/粘贴到一个新请求中,然后右键单击每个请求并将它们添加到您的测试用例中。

于 2010-07-07T02:56:49.657 回答