Contributions
Re: JSON as dataSource
Thanks again Rao ... I implemented your suggestion above ... almost there. Missing ROW 6 . ROW 1 - ProcedureTable1, columnAA ROW 2 - ProcedureTable1, columnBB ROW 3 - ProcedureTable1, columnCC ROW 4 - ProcedureTable2, columnAA ROW 5 - ProcedureTable2, columnBB ROW 6 - ProcedureTable3, columnAA - this row is not processed By reviewing the script log ... i can see that The data loop starts executing the "GroovyDataSource" test stepfor row = 5 (see script log in screen capture below - "row = 5" is present in the script log); The "GroovyScript1" test step logs the table name & column name from the"GroovyDataSource" test step. This log info does NOT appear in the script log below for row 5. Thanks again for all your help.5 years agoPlace ReadyAPI QuestionsReadyAPI Questions3KViews0likes2CommentsRe: JSON as dataSource
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] }5 years agoPlace ReadyAPI QuestionsReadyAPI Questions3.1KViews0likes4CommentsJSON as dataSource
I am trying to read a JSON file in as a DataSource test step (see JSON below). The number of nodes of the properties (named "columns") varies with each tableName in the JSON file. Is it possible to read in row by row and end up with the simple result posted below? It seems like this should be simple, but I've been struggling for hours! Thanks! INPUT JSON FILE { "ontologyName": "Procedure", "linkedResources": [{ "tableName": "ProcedureTable1", "columns": [ "columnAA", "columnBB", "columnCC" ] }, { "tableName": "ProcedureTable2", "columns": [ "columnAA", "columnBB" ] }, { "tableName": "ProcedureTable3", "columns": [ "columnAA" ] } ] } DESIRED OUTPUT ProcedureTable1,columnAA ProcedureTable1,columnBB ProcedureTable1,columnCC ProcedureTable2,columnAA ProcedureTable2,columnBB ProcedureTable3,columnAASolved3.2KViews0likes8CommentsRe: Is it possible to update a test suite property from groovy step that is in another test suite?
Or did you mean to say "I confirmed the above does NOT work in a script assertion" ... confused as to why you would want to delete the post if it does work ? Thanks again5 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.7KViews0likes0CommentsRe: Is it possible to update a test suite property from groovy step that is in another test suite?
Thanks for your suggestion. def project = messageExchange.modelItem.testStep.testCase.testSuite.project project.getTestSuiteByName("Test Suite Name").setPropertyValue("propertyName", "Property Value") I copied into a groovy script test step I replaced "Test Suite Name" with the name of one of my test suites I replaced “propertyName” with the name of a property within that test suite. The entire script now reads as follows: ----------------------------- def project = messageExchange.modelItem.testStep.testCase.testSuite.project project.getTestSuiteByName("RetrieveSecretsFromKeyVault").setPropertyValue("Token3", "xxx") ----------------------------- I get the following error: groovy.lang.MissingPropertyException:No such property:messageExchange for class: Script5 error at line: 1. Am I missing something ? TIA for your help!5 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.7KViews0likes2CommentsIs it possible to update a test suite property from groovy step that is in another test suite?
In Test Suite A Test Case A I have agroovy test step (in test suite A) that I want to update the value in aproperty of Test Suite B. Test Suite B Is this possible with groovy ?Solved5 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.8KViews0likes8CommentsHow to read in multiple JSON files with DataSource and parse when # of child nodes differs ?
I am reading in 400+ JSON files from a directory using DataSource. Each individual JSON file is imported into a test step property using DataSource test step with Source = Directory I am then using DataSource test step with Source = JSON to read in the JSON from thetest step property for parsing. I want to do this in nested DataSourceLoops so that for each of the 400+ files I am reading in all the combinations of tableName and columns The number of tableNames and columns varies by file, but the structure of all files is identical Desired output is listed below. I am able to loop through the files and successfully obtain the ontologyName and the table names, but having difficulty with the column names Can anyone help? Scroll down for desired output and raw JSON. Thanks! { JSON FILE 1 { "ontologyName": "Resource01", "linkedResources": [ { "tableName": "Table01", "columns": [ "Resource01 - Table01 - a_reference", "Resource01 - Table01 - b_reference", "Resource01 - Table01 - c_reference", "Resource01 - Table01 - d_reference", "Resource01 - Table01 - e_reference" ] } ] } JSON FILE 2 { "ontologyName": "Resource02", "linkedResources": [ { "tableName": "Table01", "columns": [ "Resource02 - Table01 - a_reference", "Resource02 - Table01 - b_reference" ] }, { "tableName": "Table02", "columns": [ "Resource02 - Table02 - a_reference", "Resource02 - Table02 - b_reference", "Resource02 - Table02 - c_reference" ] },{ "tableName": "Table03", "columns": [ "Resource02 - Table03 - a_reference", "Resource02 - Table03 - b_reference", "Resource02 - Table03 - c_reference", "Resource02 - Table03 - d_reference", "Resource02 - Table03 - e_reference" ] } ] }1.4KViews0likes1Comment