【发布时间】:2010-07-01 19:22:42
【问题描述】:
我有一堆 XML 格式的 SOAP 请求消息。有没有办法将它们导入 SoapUI 项目?
我想将它们导入并作为“测试请求”测试步骤添加到现有测试用例中。
【问题讨论】:
标签: java web-services wsdl soapui
我有一堆 XML 格式的 SOAP 请求消息。有没有办法将它们导入 SoapUI 项目?
我想将它们导入并作为“测试请求”测试步骤添加到现有测试用例中。
【问题讨论】:
标签: java web-services wsdl soapui
一种简单且更自动化的方法是使用 groovy 脚本从您拥有 xml 请求文件的目录中自动创建 testStep 请求:
你在 groovy 代码执行之前的 SOAPUI 如下所示:
以及必要的 groovy 代码:
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())
}
希望这会有所帮助,
【讨论】:
/your_xml_request_directory/ 指的是绝对路径。我不确定,但我想如果你使用相对路径,它是相对于 soapui 执行目录的。
将每个请求复制/粘贴到一个新请求中,然后右键单击每个请求并将它们添加到您的测试用例中。
【讨论】:
或者在请求视图中打开上下文菜单时选择“加载自...”。
【讨论】:
另一种选择是:
【讨论】: