langly
15 years agoNew Contributor
Test Request and Property and Groovy Script
Hello
I try to define a property in TestRequest. but i have a problem.
I have create a test case. In my test case i add a step: a test Request:
My Groovy script
My problem:
the variable query is not replace by the value define in my groovy script. I don't know why. The request is send. I try to set the value of property in test case, test suite and test step but i never succeed
Please help me.
I try to define a property in TestRequest. but i have a problem.
I have create a test case. In my test case i add a step: a test Request:
...
<searchQuery>${query}</searchQuery>
...
My Groovy script
import com.eviware.soapui.model.testsuite.TestRunner.Status
def ts = testRunner.testCase.testSuite
def tc = ts.getTestCaseByName("Test Case")
//differente search
def queries = ['query1', 'query2']
for (query in queries){
tc.setPropertyValue("query", query)
ts.setPropertyValue("query", query)
def tstep = tc.getTestStepByName("Test Request")
tstep.setPropertyValue("query", query)
def runner = tc.run(null, false)
def results = runner.results
def mes = results.messageExchanges
def request = mes.requestContentAsXml
log.info "The request: $request"
assert runner.status != Status.FAILED:runner.reason
}
My problem:
the variable query is not replace by the value define in my groovy script. I don't know why. The request is send. I try to set the value of property in test case, test suite and test step but i never succeed
Please help me.