cancel
Showing results for 
Search instead for 
Did you mean: 

How to write test result to excel file

New Contributor

How to write test result to excel file

I need to write the test result (Pass / Fail) to my test data file.

In my test data file, every 4 rows is one request, so I need to write one test result every 4 rows.

That means I need to know which row to wirte the test result.

There are 2 ways to do this as I know so far:

1. use POI to write the excel file, but I get error CTExtensionList. I don't find a way to fix it yet

2. use datasink context pointer. I don't know if SoapUI has this function or not. Can we write mutiple rows to output excel file (DataSink) in one groovy script step? I mean if we can write one row of Excel file, then move to next row in one step?

 

Thanks

5 REPLIES 5
Highlighted
Community Leader

Re: How to write test result to excel file

Hi @Jason1,

 

In my way using of POI or JXL will be a good approach, as you can moulde your groovy code according to your need.

If you are facing any issue with groovy code please attach a screenshot of error, may be we can help.

 

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
New Contributor

Re: How to write test result to excel file

This is the code I used in SoapUI:

 

def filePath = "C:/Work/Data/Sasktel/Commercail Wireless/1. Internal Flags/OR/OR-ICT00345.xlsx"

FileInputStream inputStream = new FileInputStream(new File(filePath));

XSSFWorkbook workbook = new XSSFWorkbook(inputStream);

XSSFSheet sheet = workbook.getSheetAt(0);

rowNumInt = rowNumInt + 1

Row row = sheet.createRow(rowNumInt);

Cell cell = row.createCell(25);

cell.setCellValue(result);

inputStream.close();

 

FileOutputStream outputStream = new FileOutputStream(filePath);

workbook.write(outputStream);

workbook.close();

outputStream.close();

 

This is the exception I get:

 

ERROR:java.lang.NoClassDefFoundError: org/openxmlformats/schemas/spreadsheetml/x2006/main/CTExtensionList
java.lang.NoClassDefFoundError: org/openxmlformats/schemas/spreadsheetml/x2006/main/CTExtensionList

 

Do you have a solution to fix this?

Thanks

Highlighted
Community Leader

Re: How to write test result to excel file

Hi @Jason1,

 

Hope below thread will help you in solving your problem:

 

java lang NoClassDefFoundError with Apache POI

 

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
Frequent Contributor

Re: How to write test result to excel file

firstly, to ensure you import required package, as follows:

import org.apache.poi.ss.usermodel.Cell
import org.apache.poi.ss.usermodel.Row
import org.apache.poi.xssf.usermodel.XSSFSheet
import org.apache.poi.xssf.usermodel.XSSFWorkbook

 secondly, you'd better to use try...catch for any I/O operation, as like

 try {
            FileOutputStream outputStream = new FileOutputStream(FILE_NAME)
            workbook.write(outputStream)
            workbook.close()
        } catch (FileNotFoundException e) {
            e.printStackTrace()
        } catch (IOException e) {
            e.printStackTrace()
        }
Highlighted
Moderator

Re: How to write test result to excel file

Hi all,

 

@aaronpliu@HimanshuTayal, thank you for your time looking into this!

 

@Jason1, did you manage to accomplish your task? If your question was answered, don't hesitate to mark the reply that helped you as a solution to this topic. You can do this by clicking the Accept as Solution button below the appropriate reply. 

We are looking forward to hearing from you.

 

 


Olga Terentieva
SmartBear Assistant Community Manager

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors