Issue:
Facing the error message below when having more than 403+ lines of code:
groovyjarjarasm.asm.MethodTooLargeException: Method too large: Script1589375217727.run ()Ljava/lang/Object;
at groovyjarjarasm.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2087)
Solution:
A Test Case of Katalon Studio makes a method of a class that runs on Java VM. The Java Virtual Machine has a limitation that methods cannot be larger than 64k (65536 bytes). Please review https://stackoverflow.com/questions/24256316/method-code-too-large-in-groovy-grails 54 for more info.
That's the reason why we recommend you overcome this issue is simply splitting your large method into smaller ones (not using Call Test Case), which is generally a good practice.
Please refer to the sample below.
Assume this is your test case script:
// Step 1
// Step 2
// Step 3
// ...
// Step 403
Modify the script like this:
def part_1() {
// Step 1
// Step 2
// Step 3
// ...
// Step 100
}
def part_2() {
// Step 101
// Step 102
// Step 103
// ...
// Step 200
}
// keep going until all steps are incorporated. Then...
// call part 1
part_1()
// call part 2
part_2()
// ...
// call part 50
part_50()
// etc ...
Besides, there is no current maximum line of code (LoC) of a test case but the maximum LoC in the main steps of the test case should depend on the complexity of the test script. Eg: below, the first line is more complex than the second line.
WebUI.waitForElementPresent(findTestObject('Pages/Shop page/lnkShop'), GlobalVariable.waitPresentTimeout)
WebUI.closeBrowser()
The more complex of the test case, the lesser limit of LoC. We can run the test case with 900 LoC and 436 steps without the issue.
The advice is to keep the manual steps(viewed in the Manual tab) of a test case under 100 steps. If the number of steps is over, we should break it into smaller ones.
The below is 2 LoC for a single manual step:
Comments
0 comments
Please sign in to leave a comment.