Method code too large

@spullabhotla,

In my reproduction, I could find a Groovy script <project directory>/Libs/TempTestSuitexxxxxxxxxxx.groovy of which size is 1,229,051 bytes. Its content is like this:

import com.kms.katalon.core.logging.KeywordLogger
import com.kms.katalon.core.exception.StepFailedException
import com.kms.katalon.core.reporting.ReportUtil
import com.kms.katalon.core.main.TestCaseMain
import com.kms.katalon.core.testdata.TestDataColumn
import com.kms.katalon.core.testcase.TestCaseBinding
import com.kms.katalon.core.driver.internal.DriverCleanerCollector
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.configuration.RunConfiguration
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import internal.GlobalVariable as GlobalVariable

Map<String, String> suiteProperties = new HashMap<String, String>();
suiteProperties.put('id', 'Test Suites/TS1')
suiteProperties.put('name', 'TS1')
suiteProperties.put('description', '')
DriverCleanerCollector.getInstance().addDriverCleaner(new com.kms.katalon.core.webui.contribution.WebUiDriverCleaner())
DriverCleanerCollector.getInstance().addDriverCleaner(new com.kms.katalon.core.mobile.contribution.MobileDriverCleaner())
DriverCleanerCollector.getInstance().addDriverCleaner(new com.kms.katalon.core.cucumber.keyword.internal.CucumberDriverCleaner())
RunConfiguration.setExecutionSettingFile("C:\\Users\\qcq0264\\tmp\\spullabhotla\\MethodCodeTooLarge\\Reports\\TS1\\20190325_155544\\execution.properties")
TestCaseMain.beforeStart()

TestCaseMain.startTestSuite('Test Suites/TS1', suiteProperties, [new TestCaseBinding('Test Cases/TC1 - Iteration 1', 'Test Cases/TC1',  [ 'campaign' : '59a5dd9c8b6d8947e0dc042a' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 2', 'Test Cases/TC1',  [ 'campaign' : '59a5de761b761325901ac21b' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 3', 'Test Cases/TC1',  [ 'campaign' : '59a5de781b761325901ac21c' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 4', 'Test Cases/TC1',  [ 'campaign' : '59a5de9159846636ccce487b' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 5', 'Test Cases/TC1',  [ 'campaign' : '59a5df15fc8c3d72bc6ff759' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 6', 'Test Cases/TC1',  [ 'campaign' : '59a5e0582e067d4f30c910bb' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 7', 'Test Cases/TC1',  [ 'campaign' : '59a5e07cf72e8e75643ec3b3' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 8', 'Test Cases/TC1',  [ 'campaign' : '59a5e0c2dff8f04210f0b1ce' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 9', 'Test Cases/TC1',  [ 'campaign' : '59a5e0d629e8e055a03805a6' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 10', 'Test Cases/TC1',  [ 'campaign' : '59a5e10e7e52f9602ce9e3c7' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 11', 'Test Cases/TC1',  [ 'campaign' : '59a5e11f498ff154b8ccc4d0' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 12', 'Test Cases/TC1',  [ 'campaign' : '59a5e1474526846418e7032f' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 13', 'Test Cases/TC1',  [ 'campaign' : '59a5e163878052655c073a1e' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 14', 'Test Cases/TC1',  [ 'campaign' : '59a5e18978674e4b1cde132f' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 15', 'Test Cases/TC1',  [ 'campaign' : '59a5e19a40ea6e693003ab48' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 16', 'Test Cases/TC1',  [ 'campaign' : '59a5e1a6045bc02d0c5023cb' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 17', 'Test Cases/TC1',  [ 'campaign' : '59a5e211ce45101ec032c648' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 18', 'Test Cases/TC1',  [ 'campaign' : '59a5e29508eb7c0a94865a8f' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 19', 'Test Cases/TC1',  [ 'campaign' : '59a5e335a7a714425ca3649d' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 20', 'Test Cases/TC1',  [ 'campaign' : '59a704a41289a733b041a15b' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 21', 'Test Cases/TC1',  [ 'campaign' : '59a704ba0ea5e74db41b8be9' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 22', 'Test Cases/TC1',  [ 'campaign' : '59a708447a64e903bc8784d8' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 23', 'Test Cases/TC1',  [ 'campaign' : '59a708547a64e903bc8784da' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 24', 'Test Cases/TC1',  [ 'campaign' : '59a708ee0c87482a0466ee85' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 25', 'Test Cases/TC1',  [ 'campaign' : '59a73f443298b351f84622d2' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 26', 'Test Cases/TC1',  [ 'campaign' : '59a73faf4535402ef866f9bc' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/TC1 - Iteration 27', 'Test Cases/TC1',  [ 'campaign' : '59a73fd56464ca2ee04c2239' , 'event' : 'Receive' ,  ]), new TestCaseBinding('Test Cases/T ........................................................ 

Obviously this is the implementation of the failing Test Suite. It has a terribly long literal of List<TestCaseBinding> which represents data in the CSV file. This is the cause of Method code too large!.

I believe you would find a similar TempTestSuitexxxxx.groovy file in your project.

1 Like

@kazurayam

Thank you very much for the thorough investigation and suggestion. I will go ahead and use the Plan B/Method B for implementing using the For Loop. I will update on this shortly.

Appreciate your time and support.

Same issue in version 5.8.6 (stack below), test suite/test case works fine in 5.2.x
Had to migrate to 5.8.6 because getStatusCode() was not working in 5.2.x and cannot use 6.1.x due to many HAR files generated.

Getting very frustrated with KS the more I use it! But time to ditch KS and say good bye to this community. Thank you everyone for your support.

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 com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:188)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:183)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:108)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:294)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:285)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:264)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:256)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:200)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:99)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.doCall(CallTestCaseKeyword.groovy:60)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.call(CallTestCaseKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:54)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword.callTestCase(CallTestCaseKeyword.groovy:81)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword.execute(CallTestCaseKeyword.groovy:45)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:53)
at com.kms.katalon.core.keyword.BuiltinKeywords.callTestCase(BuiltinKeywords.groovy:334)
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.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1469)
at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141)
at Script1553649631726.run(Script1553649631726.groovy:55)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:183)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:108)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:294)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:285)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:264)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:256)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:200)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:129)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:112)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:81)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141)
at TempTestSuite1553712727950.run(TempTestSuite1553712727950.groovy:36)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
at groovy.lang.GroovyShell.run(GroovyShell.java:518)
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)

@ai_test,

In the <project folder>\Libs folder, I suppose you will find a file named TempTestxxxxxxxxxx.groovy of which size is VERY LARGE (for example 1 mega bytes). For example, in my project on my PC I can see the following:

If you can find a giant *.groovy file, then the file is probably the cause of the Runtime Exception with “Method code too large!” message. The groovy script file is so large that Groovy compiler is unable to compile it.

Please check your project’s Libs folder to see if you find a large file or not.

1 Like

Any update from the katalon team about this issue ?
i have the same problem although the groovy file is not very large (around 200kb)

1 Like

Hi all,
One of the major reasons that cause method code too large exception is the use of big test data. We will fix this issue in upcoming releases.
Regards.

Updated to v6.3.1 now I am getting “method code too large” error. it did not happen before the update.

Hi @jenkinsmorgan04,
How does the issue happen?

@huynguyen I never use test data in form of data binding but I use a database to access test data.

I always get method code too large error when I have a script going over 1000 lines.

that is a groovy limitation. on the other side, why somebody will need an > 800 lines test?

I have a guess. It is because they use Katalon’s Web Recorder tool to generate a test case script.

With it, they record their operation over dozens of pages as one sequence. Each page may contain dozens of web elements to look at. Then the Web Recorder tool likely generates a lengthy test case script of >800 lines.

@Ibus @kazurayam I am not using Katalon Web Recorder for creating script. I have a test case which is running on a Jenkins server every 30 mins for each of our website.

The test case perform some important testing along the way till checkout page. There are many important validations it do. Our websites have many 3rd party components and payment processors where we need to keep an eye. The code is also printing a lot of information in logs based on logic and data. This is then feed into Analytics where Management team can see it whenever they want.

@Ibus I don’t see why someone couldn’t have more than > 800 lines test ? It depends on what the requirements we have to test.

well … i do understand that you have many requirements. but in such cases, my approach will be to split the scope of the test in smaller components > more smaller testcases instead of a huge script. it’s just a matter of taste, i hate to debug into thousand lines of code

@Ibus I had similar approach earlier, but because the requirement to read / write into database based on the content and action performed the code started getting lengthier. To overcome the method code too large issue I have separated the code into some small scripts and call those using Call Test Case method in one main script.

yeah, that may work too. and is also easier to debug, since in case of failure you will know exactly what sub-case had issues

Hi all,

This issue @kazurayam mentioned above has been fixed in v6.3.x. Please check again.

https://docs.katalon.com/katalon-studio/new/version-630.html#fixes

Thanks

@duyluong

”Method code too large” and “a test suite with too large test data” — are these 2 problems the same issue?

Could you please show us a bit more info what “a test suite with too large test data” issue is? How Katalon Studio has been changed? Any link to a forum issue?

Hi @kazurayam,

There are 2 problems in this topic:

  1. The issue relates to a test suite using data binding with large Test Data. We already fixed it.
  1. The issue relates to a test case contains 500-1000 lines of code. This is a Groovy limitation. We may try to improve but we also recommend users to separate the main script to multiple methods.

Thanks.

1 Like

OK, I understand it. Thanks for the clarification.

1 Like

I’m testing a single page form with around 70 elements. Every box in the form needs to be completed. The success or failure of the test is based on whether the page can submit. They have promised the client that we will produce a result with short turnaround. Katalon seemed to streamline the Selenium process. I got to 65 elements and now I got this exception.

70 elements and 700 lines of code is too much, maybe Katalon is better for unit tests and not web page tests.

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during class generation: Method code too large!