import com.eviware.soapui.support.*; //import groovy.json.JsonSlurper //def json = new JsonBuilder() // Try-catch block to handle exceptions try { //1. Get Current date time stamp to append the same in the file name. def date = new Date() def dts = date.format("yyyy-MM-dd-HH-mm-ss-ms") //2. Create report file in the specified location def reportFile = "C:/Users/sharath/Documents/Varnikha/Rest projects/" + "ExecutionReport" + ".csv" def report = new File(reportFile) if (!report.exists()) { report.createNewFile() report.write('"Test Suite Name","Test Case ID","Test Step Name","Assertion Name","Step Status","Result Message","Execution Date"') } //3. Retrieve Test case ID def myTestCase = context.testCase def propTestStep = myTestCase.getTestStepByName("DataDriver") def TestCaseID = propTestStep.getPropertyValue("TestCaseID").toString() //4. Create request and response files def myjsonRequest = "C:/Users/sharath/Documents/Varnikha/Rest projects/" + TestCaseID + "_" + "AddPet_" + "Request" + ".json" def request = context.expand('${AddPet_POST#Request}') def req = new File(myjsonRequest) req.write(request, "UTF-8") def myjsonResponse = "C:/Users/sharath/Documents/Varnikha/Rest projects/" + TestCaseID + "_" + "AddPet_" + "Response" + ".json" def response = context.expand('${AddPet_POST#Response}') def res = new File(myjsonResponse) response.with(groovy.json.JsonOutput.&prettyPrint) res.write(response,"UTF-8") assert true } catch (exc) { log.error("Exception happened: " + exc.toString()); }