Forum Discussion
14 Replies
- groovyguyCommunity Hero
You may want to provide more details. Most helpful would be the groovy script you are trying to use and the error you are receiving. Without that, it is very hard to figure out what the problem may be.
- PavithraROccasional Contributor
Hi,
Below is the Groovy Script:
import java.text.Format;
import java.text.SimpleDateFormat;import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment
import org.apache.poi.ss.usermodel.BorderStyle;import java.text.Format;
import java.text.SimpleDateFormat;import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment
import org.apache.poi.ss.usermodel.BorderStyle;import com.eviware.soapui.impl.wsdl.support.assertions.*
def resultPath = context.expand('${#Global# ResultPath}');
def currTimeStamp = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date());
int rowNo = 0;XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Execution_Results");
Row row = sheet.createRow(rowNo++);row.createCell(0).setCellValue("ProjectName");
row.createCell(1).setCellValue("TestSuite");
row.createCell(2).setCellValue("TestCase");
row.createCell(3).setCellValue("StatusName");
row.createCell(4).setCellValue("TimeStamp");
for (project in com.eviware.soapui.SoapUI.workspace.projectList) {
if (project.name != testRunner.testCase.testSuite.project.name) {
for (testSuite in project.getTestSuiteList()) {
for (testCase in testSuite.getTestCaseList()) {
for (testStep in testCase.getTestStepList()) {
stepResult = testStep.run(testRunner, context);
Date date = new Date(stepResult.getTimeStamp());
Format format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// status = testStep.testRequest.getResponse().getResponseHeaders().get("#status_code#");
timeStamp = format.format(date);
if (stepResult == null) {
respData = "No response received";
} else {
respData = stepResult;
}
timeTaken = stepResult.getTimeTaken() + " ms";
int colNo = 0;
row = sheet.createRow(rowNo++);
row.createCell(colNo++).setCellValue(project.name);
row.createCell(colNo++).setCellValue(testSuite.name);
row.createCell(colNo++).setCellValue(testCase.name);
row.createCell(colNo++).setCellValue(status.name);
row.createCell(colNo++).setCellValue(timeStamp);
//log.info testStep.testRequest.getResponse().getResponseHeaders();
//log.info testStep.testRequest.getResponse().getResponseHeaders().get("#status#");
}
}
}
}
}try {
FileOutputStream fos = new FileOutputStream("D:/"+Filename.xlsx);
workbook.write(fos);
workbook.close();
}
catch (Exception e) {
log.info (e.printStackTrace());
}Regards,
Pavithra R
Related Content
- 2 years ago
- 2 years ago