Method code too large

Same probleme here! I am looking forward for a fix :slight_smile:

Btw: It’s my first time of using Katalon. This bug is defenitly a show stopper.

5 Likes

@Felix Hoess

Katalon is still very very functional and has a lot of power. The GUI for writing automation is huge. I broke my test up into 3. I still am capture alot, I just dont like having to back to the page. But this test was a general functionality “smoke test” so it was much bigger then my typical one.

Hi All,

I am getting same error when i use data file with more then 500 rows, till 500 rows it works fine. I tested this in 5.2 version and it works fine. This seems to be issue with 5.4. Please confirm if there is going to be fix for this in next version of Katalon.

Hi,

Same issue here. Is there a way to get previous Katalon Studio versions (like 5.2 on mac)? I really don’t want to split test cases.

Found out how to download an older version:

Thank you.

Hi Katalon Team,

Is this issue going to get fixed in new version ? I validated this in 5.5 and it is still an issue. Is there a workaround/solution available.

Thanks & Regards
Vikas

I am also getting the same issue and I deleted some data from excel sheet which I am using as Data input, deleted blank lines and restarted the Kataloan
resolves my issue.

I’m on v5.6.1 and getting the issue with 417 line items. I’ll be shrinking my code later as I learn the tool, but this limitation is troublesome to the learning process.

A Test Case of Katalon Studio makes a method of a class which runs on Java VM.

The Java Virtual Machine has a limitation that a single method cannot be larger than 64k (65536 bytes) in size. See https://stackoverflow.com/questions/24256316/method-code-too-large-in-groovy-grails for more info.

Katalon Studio would never, I suppose, become capable of handling a large test case exceeding the Java VM limitation. If you encounter the “Method code too large!” problem, you have no other choice but shrinking your test case code.

I would suggest splitting your large test case into a set of smaller test cases making sure each of them smaller than the JVM limitation. And you add a test case which invokes other worker test cases using WebUI.callTestCase().

[ a large test case ]  >>>>> [caller test case]
                                                -> [callee test case 1]
                                                -> [callee test case 2]
                                                -> [callee test case 3]
                                                -> ...
                                                    smaller codes as many as you want

edited at 8 Jan, 2020

… splitting your large test case into a set of smaller test cases … (then re-assemble them) using WebUI.callTestCase()

No. It does not help. I found that WebUI.callTestCase() concatenates the code of callee scripts into the caller to form a single large method. If the caller script has 100 lines of script, and the callee script has 400 lines, then at runtime we will have a single method of 100 + 400 = 500 lines. In terms of JVM method size, this approach does not make any effect.

No need to say, a straight forward refactoring would be
splitting a large Test Case into smaller pieces, and bind them by a Test Suite, if possible.

[ a large test case A]  >>>>> [Test Suite X]
                                                -> [test case 1]
                                                -> [test case 2]
                                                -> [test case 3]
                                                -> ...
                                                    smaller codes as many as you want
3 Likes

Upvoted

Kaz, you should make that an article or Tips and Tricks post.

Charles, the originator of this discussion, said:

In the Manual view, it’s 1409 lines (items).

How come has he got such a big test case! I was surprised.

Such a mighty test case can not be written by hand. I guess that this big code must have been generated by Web Recorder of Katalon Studio. I can remember how Web Recorder behaves when I start visiting the site http://demoaut.katalon.com/ and navigated through 4 different web pages. In the end the Web Recorder generates a single (fairly large) code as test case. Charles and others possibly used Web Recorder and went through 10 pages, 20 pages or more. A long recording resulted, I guess, 1409 lines.

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, a premature draft, or a sketch which requires careful refinement. I would read the generated code, understand it, and find semantical borders. 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 completion. But I swear the code generation is just a start. You have long way to go for continuous rethink and rewriting codes.

1 Like

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.

1 Like

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

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: http://forum.katalon.com/discussion/comment/15608/#Comment_15608

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

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).

@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.

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

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)

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.

Could you share the execution log with error messages?