Solved
Forum Discussion
nmrao
5 years agoChampion Level 3
Please see if the below helps.
Note that, don't know exactly in which cell you want to put the data n could not test. Give it a try.
context.testCase.testStepList.findAll { it instanceof RestTestRequestStep}.each { step -> def k = context.testCase.getTestStepIndexByName(step.name) + 1 for (j = 1; j < no_of_rows; j++) { Cell f = inputSheet.getCell(0, j) step_name = f.getContents() Cell f1 = inputSheet.getCell(3, j) def step_response = f1.getContents() def response = context.expand(step.getPropertyValue('Response')) if (response != null) { response = response.replaceAll(" ", "") } if (step_response != null) { step_response = step_response.replaceAll(" ", "") } if ((step.name == step_name) && (step_response != '')) { try { JSONAssert.assertEquals(step_response, response, false) log.info k log.info step_name log.info "from excel" + step_response log.info "from UI" + response jxl.write.Label status = new jxl.write.Label(1, k, "Passed") sheet_writable.addCell(status) pass_count = pass_count + 1 } catch (AssertionError e) { log.info "${e}" String exception = e.toString() exception = exception.replace("java.lang.AssertionError:", "") jxl.write.Label status = new jxl.write.Label(1, k, "Failed") sheet_writable.addCell(status) jxl.write.Label reason = new jxl.write.Label(5, k, exception) sheet_writable.addCell(reason) fail_count = fail_count + 1 } } else if ((step.name == step_name) && (response == null)) { if (response == null) { log.info "from else " + k log.info "response from if" + response jxl.write.Label status = new jxl.write.Label(1, k, "Passed") sheet_writable.addCell(status) pass_count = pass_count + 1 } else { jxl.write.Label status = new jxl.write.Label(1, k, "Failed") sheet_writable.addCell(status) fail_count = fail_count + 1 } } } }
Removed incremens of k as not needed.
Related Content
Recent Discussions
- 6 days agoruchisingh