Last active
April 7, 2016 13:26
-
-
Save gerbrand/9681875 to your computer and use it in GitHub Desktop.
A SOAPUI-project file contained a testsuite. The testsuite consisted of (xml) requests to a certain rest-service. I wanted to extract all those request-messages to use them in my own test. Doing that by hand was a bit cumbersome and boring. I decided to write a small script for do that in Scala. Writing the script was a lot easier then doing it …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.xml._ | |
import java.io._ | |
/** | |
* Small script to extract the request-xml-messages from a soapui project | |
*/ | |
object SoapUIExtractor extends App { | |
def writeTestStep(teststep:Node) { | |
val requestContent = (teststep \ "config" \ "restRequest" \ "request").head.child(0).text | |
val testCaseName = (teststep \ "@name").head.text | |
val filename = testCaseName+".xml" | |
println(filename) | |
val writer = new PrintWriter(new File( filename )) | |
writer.write(requestContent) | |
writer.close() | |
println(requestContent) | |
} | |
val soapUI = XML.loadFile("my_soapui-project.xml") | |
//extract all test cases and write the request-xml that's contained in each test-case | |
(soapUI \\ "soapui-project" \ "testSuite" \ "testCase" \ "testStep" ).foreach ( r => writeTestStep(r) ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment