Method code too large


#21

Worth Repeating:

Web Recorder would generate a big code. That’s OK. That’s the way it
works. But one thing, I always regard the generated code as a material,
premature draft, or sketch which requires careful refinement. I would
read the generated code, understand it, and find boundary of lines by
semantics, then I would split it into a set of code snippets of
manageable size.

I am rather afraid that those who are new to
Katalon Studio may expect the test case code generated by Web Recorder
is near to completion. But I swear, code generation is just a start. You
have long way to go for rethink and rewriting codes.


#22

I got the same error in 5.7.0. But all scripts worked fine in 5.2.x.


#23

HYN said:

I got the same error in 5.7.0. But all scripts worked fine in 5.2.x.

They stopped working after version 5.3.1 if i recall correctly.

You can read here: https://forum.katalon.com/discussion/comment/15608/#Comment_15608


#24

I worked around.
It worked well when splitting test suites and add all in test suite collection on Katalon 5.7.0.


#25

Im experiencing this and I dont have 500 lines…more like 400, which is really not alot, especially when you write test by hand (not record). Nevertheless, it seems we either learn the keywords and custom methods or else we are SOL with our scripts lol… Not preferred at all, but if this is the case, the tutorial should at least be much much more comprehensible and easy to apply to our own scripts (creating, implementing, using Keyword, etc).


#26

@kazurayam
I am getting the same error for API testing for a CSV file that has over 8K lines of records. How can I implement this method for API. What is a caller test case for a large test case and how the worker test cases can be implemented. Please help getting this understand. Appreciate your help.


#27

We need to understand your problem first. Please share your test case code and the log, and preferably you CSV file.


#28

Thank you for the quick response.

Here is the link for the code and the csv file is attached.
http://dpaste.com/3SNBR2E

AllCampaigns.zip (47.6 KB)


#29

spullabhotla,

I read your test case code. Your code seems to have nothing related to the csv file. I found no fragment which reads the csv file. I am confused.


#30

Could you share the execution log with error messages?


#31

@kazurayam
I have used the json payload file wherein the payload has the variables to fetch the data from csv. The CSV files are uploaded in Data Files section of Katalon Studio.

I have then created the Test Suite and added Data File to it.


#32

Your test seems to be complexed enough. I do not understand it.


#33

Here is the log message -

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

Picked up _JAVA_OPTIONS: -Xmx2048M


#34

Could you share the "C:\\Users\\sp\\Desktop\\ATS\\logUnique.json" file which is refered by the test case script?


#35

Please find the link below for JSON -

http://dpaste.com/1BYXQD4


#36

Could you take screenshot of the Test Object 'events/EventsLogUnique' and share it?


#37

I do not understand what you mean here. Could you elaborate it?


#38

Please find the screen capture for the same.


#39

As you can see, the stack trace message does not tell you which portion of your test scripts is causing the RuntimeException.

I presume the test case is NOT causing java.lang.RuntimeException: Method code too large!. I think so because your test case code at http://dpaste.com/3SNBR2E has nothing to do with the Data File http://dpaste.com/1BYXQD4 . Possibly you have other script which might be the real cause of the RuntimeException. Please check your code and identify what is causing the exception.


#40

I could reproduce Method code too large! exception on my side. I have created a project in GitHub, with which you can reproduce this incident.


@spullabhotla

Please read the Document “Data-driven testing approach with Katalon Studio”

The document introduces two methods of Data-driven Tests Execution, that is:

  • A. EXECUTION FROM TEST SUITES
  • B. EXECUTE USING A TEST CASE

I believe you followed the method A. I am sure that the A method generates a single test suite script which contains a very long literal which represents whole data in the given CSV file. This would cause Method code too large! exception.

Please try the method B as an alternative. The method B tells you to code for loop over the Data file lines. The for loop would enable you to avoid Method code too large! exception.