I have a bunch of SOAP request messages in XML format. Is there a way to import them to a SoapUI project?
I want to import them and add开发者_如何学JAVA as "Test Request" Test Step to an existing Test Case.
An easy and more automatic way to do so is using a groovy script to automatically create the testStep request from a directory where you have you xml request files:
- Create a TestCase manually.
- Add an empty TestStep request which we will use as a template to create the other requests.
- Add a groovy testStep which imports all files using the code below, and execute it in order to create the testSteps.
Your SOAPUI before groovy code execution looks like:
And the necessary groovy code:
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())
}
Hope this helps,
Copy/paste each into a new request, then right click on each request and add them to your test case.
Or select "Load from..." when opening the context menu in the request view.
Another option is:
- Create a soapui project with one request
- Open the soapui-project XML file
- Search for con:call part
- Duplicate it and replace the con:request with your own XML request
- Save and reload the project in soapui
精彩评论