I using map that transfer through global variable between test case. There is a step in my script that declares the map from global variable. And there are 2 declare ways that auto correct wrong syntax.
Step reproduce:
Open test case > Switch to script mode
Declare map from global:
Map dataCore = (Map) GlobalVariable.shareMap
Map dataCore1 = Map as GlobalVariable.shareMap1
2025-09-08 20:40:40.286 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/TC1 FAILED.
Reason:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:/Users/kazuakiurayama/katalon-workspace/healthcare-tests-speed-measurement-of-versions/Scripts/TC1/Script1757331524345.groovy: 4: unable to resolve class GlobalVariable.shareMap1
@ line 4, column 17.
Map dataCore1 = Map as GlobalVariable.shareMap1
^
1 error
at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:486)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:477)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:456)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:448)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:322)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:151)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:139)
at TempTestCase1757331633445.run(TempTestCase1757331633445.groovy:25)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Your original script contains a wrong code.
Yes, it is wrong because your original script was wrong.
No, the autoformatting while switching from Manual to Script view has nothing to do with the error you got.
No, my KS is v10, it do auto correct the line to the wrong format. So I recently I have to edit all my script in declare map from GV due to that. Technically I just declare like following is fine:
Switching the Test Case editor from the Manual mode to Script mode has caused a lot of problems for many users since Katalon’s early days. It is an old issue already known for years.
You should never switch the Test Case editor from the Manual view to the Script view.
If you want to use the Manual mode, then you should stay in the Manual mode. Don’t switch to the Script mode.
When you edit your Test Case script in the Manual mode and switch the editor into the Script mode, the editor will unparse the source out of the Abstract Syntax Tree object. The code generation logic does not respect the original source code that you typed. The unparsed code could be different from your original code. Even worse, It could be errorneous. The logic doesn’t “autocorrect” at all.
You should refrain from the mode switching at all. That’s all you can do.