Forum Discussion

schaubut's avatar
schaubut
New Contributor
8 years ago

Test Step not using Testcase property created by Groovy

I am new to SOAPUI Pro.

 

I am trying to understand how to use a Groovy script to transfer data read from SQL into a test case property.

I can see the SQL data displayed in the log output of the groovy script, create the test case property but I get all the values in my response.  I only want the values that come from SQL.     Also, note that I get an unexpected end-of-file as seen here.

 

 

I referenced the property that the groovy script creates in the test step  as ${#TestSuite#SQLCurrencyContry}   

 

import java.sql.DriverManager
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")
def conn = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;databaseName=SOAPUIPRO",user="sa",password="***")
def stmt = conn.createStatement()

def rs = stmt.executeQuery("SELECT CurrencyCode FROM CurrencyCode")
while (rs.next())
{
def id=rs.getString("CurrencyCode")
log.info id
//testRunner.testCase.testSuite.setPropertyValue("SQLCurrencyContry", id)
if (id != null){
testRunner.testCase.setPropertyValue("SQLCurrencyContry", id)
testRunner.runTestStepByName("req1")
}
}