Method code too large

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 Method code too large in Groovy & Grails? - Stack Overflow 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