ALL,
I have a test case that uses a data file. This data file has 2000 records in the Excel document. When I try to run the test suite in Katalon. I get an error within seconds that says :
Is there a limit on the number of records that a data file can have???
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during class generation: Method code too large!
java.lang.RuntimeException: Method code too large!
at groovyjarjarasm.asm.MethodWriter.a(Unknown Source)
at groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source)
at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:815)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.run(GroovyShell.java:517)
at groovy.lang.GroovyShell.run(GroovyShell.java:507)
at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653)
at groovy.ui.GroovyMain.run(GroovyMain.java:384)
at groovy.ui.GroovyMain.process(GroovyMain.java:370)
at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)
at groovy.ui.GroovyMain.main(GroovyMain.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
1 error
Hi,
2000 records = 2000 rows or cell data?
how excel is read, what kind of functions are used?
is the data in several sheets?
if yes read only one sheet data in a one shot.
is there possibility to read data by multiple pieces?
Hi,
i have no issues
sample excel file contains 9995 rows and 209895 cell data
TESCASE
List<String> excelValues = new ArrayList<String>();
excelPath = "C:\\Users\\xxxxx\\Desktop\\data\\SampleSuperstore.xls"
int start = 9994
int end = 9995
excelValues = CustomKeywords.'readExcelRows.ReadRows.readExcelRows'(start, end,
excelPath)
start++
System.out.println("fetch Row "+start)
for (String temp : excelValues) {
System.out.print(temp + "\t");
//println(temp + "\t")
}
rowId = excelValues.get(0)
println rowId
orderId = excelValues.get(1)
println orderId
KEYWORD
package readExcelRows
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import com.kms.katalon.core.annotation.Keyword
public class ReadRows {
public String SAMPLE_XLSX_FILE_PATH = "";
Workbook workbook
@Keyword
public List<String> readExcelRows(int start, int end, String path) throws IOException, InvalidFormatException{
SAMPLE_XLSX_FILE_PATH = path;
List<String> excelValues = new ArrayList<String>();
// Creating a Workbook from an Excel file (.xls or .xlsx)
workbook = WorkbookFactory.create(new File(SAMPLE_XLSX_FILE_PATH));
// Getting the Sheet at index zero
Sheet sheet = workbook.getSheetAt(0);
// Create a DataFormatter to format and get each cell's value as String
DataFormatter dataFormatter = new DataFormatter();
int startRow = 0
int endRow = 0;
for (Row row: sheet) {
for(Cell cell: row) {
if (startRow >= start && endRow < end){
String cellValue = dataFormatter.formatCellValue(cell);
//System.out.print(cellValue + "\t");
excelValues.add(cellValue);
}
}
startRow++;
endRow++;
//System.out.println();
}
// Closing the workbook
//workbook.close();
return excelValues;
}
}
RESULTS
fetch Row 9995
2019-04-28 19:48:31.762 DEBUG testcase.readExcel - 8: for (String temp : excelValues)
2019-04-28 19:48:31.909 DEBUG testcase.readExcel - 1: out.print(temp + " ")
9994 2019-04-28 19:48:32.044 DEBUG testcase.readExcel - 1: out.print(temp + " ")
CA-2017-119914 2019-04-28 19:48:32.200 DEBUG testcase.readExcel - 1: out.print(temp + " ")
5/4/17 2019-04-28 19:48:32.361 DEBUG testcase.readExcel - 1: out.print(temp + " ")
5/9/17 2019-04-28 19:48:32.529 DEBUG testcase.readExcel - 1: out.print(temp + " ")
Second Class 2019-04-28 19:48:32.689 DEBUG testcase.readExcel - 1: out.print(temp + " ")
CC-12220 2019-04-28 19:48:32.852 DEBUG testcase.readExcel - 1: out.print(temp + " ")
Chris Cortes 2019-04-28 19:48:33.012 DEBUG testcase.readExcel - 1: out.print(temp + " ")
Consumer 2019-04-28 19:48:33.219 DEBUG testcase.readExcel - 1: out.print(temp + " ")
United States 2019-04-28 19:48:33.245 DEBUG testcase.readExcel - 1: out.print(temp + " ")
Westminster 2019-04-28 19:48:33.354 DEBUG testcase.readExcel - 1: out.print(temp + " ")
California 2019-04-28 19:48:33.359 DEBUG testcase.readExcel - 1: out.print(temp + " ")
92683 2019-04-28 19:48:33.424 DEBUG testcase.readExcel - 1: out.print(temp + " ")
West 2019-04-28 19:48:33.434 DEBUG testcase.readExcel - 1: out.print(temp + " ")
OFF-AP-10002684 2019-04-28 19:48:33.442 DEBUG testcase.readExcel - 1: out.print(temp + " ")
Office Supplies 2019-04-28 19:48:33.445 DEBUG testcase.readExcel - 1: out.print(temp + " ")
Appliances 2019-04-28 19:48:33.450 DEBUG testcase.readExcel - 1: out.print(temp + " ")
Acco 7-Outlet Masterpiece Power Center, Wihtout Fax/Phone Line Protection 2019-04-28 19:48:33.453 DEBUG testcase.readExcel - 1: out.print(temp + " ")
243,16 2019-04-28 19:48:33.456 DEBUG testcase.readExcel - 1: out.print(temp + " ")
2 2019-04-28 19:48:33.488 DEBUG testcase.readExcel - 1: out.print(temp + " ")
0 2019-04-28 19:48:33.518 DEBUG testcase.readExcel - 1: out.print(temp + " ")
72,948 2019-04-28 19:48:33.528 DEBUG testcase.readExcel - 9: rowId = excelValues.get(0)
9994
CA-2017-119914
1 Like
Hey Timo,
thanks for the suggestions… I initially wanted a simple straight forward approach… where the test case has variables defined and the excel test data is linked(using Data Binding) to the test case in the test suite.
look i will have to explore some of the suggested workarounds thanks