This is awesome ... exactly what i was looking for to loop through and read the JSON.
I am now working on this step "2. need to define a variable and assign current row count" and am having trouble with getting the data source test step to read only a single row of the output at a time ... the step is reading all 6 rows in a single pass (of data loop) instead of only 1 row. I am also having an issue getting the test step to save the property. Can you help ? Thanks
ROW 1 - ProcedureTable1, columnAA
ROW 2 - ProcedureTable1, columnBB
ROW 3 - ProcedureTable1, columnCC
ROW 4 - ProcedureTable2, columnAA
ROW 5 - ProcedureTable2, columnBB
ROW 6 - ProcedureTable3, columnAA
here is groovy data source i am currently trying to get to work .... Thanks for any help !!!
def str = context.expand( '${DataSource-readJSON#JSONstring}' )
// Get current row
def row = testRunner.testCase.testSteps["GroovyDataSource"].currentRow;
log.info ("row = " + row)
def grid = [];
// Get a list of items in the grid array
def json = new groovy.json.JsonSlurper().parseText(str)
def data = json.linkedResources.inject([]) { list, table -> list << table.columns.collect { ['table': table.tableName, 'column': it]}; list.flatten() }
data.each {
log.info "${it.table}, ${it.column}"
}
// ***********************************
//{
// // Add the name of the file to the list
// data -> grid.add(it.table,it.column);
//}
// ***********************************
if (row < grid.size) {
// Return the name to data source's "File" property
result["table"] = it.table[row]
result["column"] = it.column[row]
}