Groovy is built on JVM, so does the SoapUI, it’s no surprise that SoapUI offers the Groovy script support by default. Let’s do a simple test, basically send out a Http request with dynamic parameters, and parse the result using the regular expression capability of Groovy and IO capablity to save the result back to a file. for the parameter we can use the groorvy to poll a file and return some randomized keywords.
we create one project with one test suite, then under the suite, we can add test case, and for the test step, let’s add first step called GetKeyword as a groovy script.
then we put some script here, which will assign a keyword property to the context randomly.
then we can access this keyword using context.keyword in next step, now, let’s create a http request to bing.com
Click extract params,now if we run this test
the query keyword is hardcoded, we can replace it with a groovy expression
then add the 3rd step, that we read the response in step 2 and save it to a file
if we run the test case, you will see file named keyword.txt with the http response from bing.com search
also you can just copy and save the following xml as a project file, you open in in SoapUI
<?xml version="1.0" encoding="UTF-8"?>