Forum Discussion
hi
i got solution for you.
example of groovy script which recover and test one database field value :
before you have : testcase property with expected values, and a JDBC Step which give you database answer :
<Results>
<ResultSet fetchSize="0">
<Row rowNumber="1">
<databasename.datafield1>123</databasename.datafield1>
...
<databasename.datafieldname>123</databasename.datafieldname>
...
</Row>
</ResultSet>
</Results>
import com.eviware.soapui.support.XmlHolder
def reponse = context.expand( '${JDBCTestStep#ResponseAsXml#//*:Results/ResultSet/Row}' )
def egal = true
if (reponse != "") {
// log.info " answer recover : " + reponse
// Test field in database
def Slurp = new XmlSlurper().parseText(reponse)
def FieldDB = Slurp."databasename.datafieldname"
// log.info " FieldDB : " + FieldDB
def FieldExpected = testRunner.testCase.getPropertyValue("FieldValueExpected")
if (FieldDB == FieldExpected ) { log.info " the field " + FieldDB + " is correct in database."}
else { egal = false; log.info " the field " + FieldDB + " is not correct in database."}
}
else { egal = false; log.info " request sent is empty !"}
assert egal
Related Content
- 9 years ago
Recent Discussions
- 15 years ago