Hi all,
My question has to do with the editor experience, and does not affect the execution of test cases, however I felt this was the appropriate section of the forum. Please let me know if I should change it.
I have a custom variable type defined in Keywords that I am using as a global variable. The issue is that in GlobalVariable.groovy
, each global variable is declared as a Java.lang.Object
, creates editor warnings, and does not allow for intellisense/autocompletion. I have included an example below.
Execution profile: default.glbl
<?xml version="1.0" encoding="UTF-8"?>
<GlobalVariableEntities>
<description></description>
<name>default</name>
<tag></tag>
<defaultProfile>true</defaultProfile>
<GlobalVariableEntity>
<description>I want to set this variable type</description>
<initValue>null</initValue>
<name>customObject</name>
</GlobalVariableEntity>
</GlobalVariableEntities>
Relevant lines from GlobalVariable.groovy:
...
public class GlobalVariable {
/**
* <p>Profile default : I want to set this variable type</p>
*/
public static Object customObject
...
How it works: Test Listeners/beforeAndAfterTestCase
@BeforeTestCase
def beforeTc(TestCaseContext testCaseContext) {
GlobalVariable.customObject = new MyCustomType(testCaseContext)
}
Test case usage:
GlobalVariable.MyCustomType.performMethod()
performMethod is usually greyed out, and there are no suggestions for any member of MyCustomType.
I have found two ways to band-aid this.
-
Add methods and variables from the custom type to
.groovy/suggestions.xdsl
. Adding each member to that file can be very time consuming, and has the added detriment of having the custom type’s members suggested for each Java.lang.Object. -
Edit
GlobalVariable.groovy
. This change is great, but doesn’t last, as the file gets rewritten each time the Katalon project is loaded.
Is there any permanent way to declare the initial type for Global Variables, or prevent Katalon from refreshing GlobalVariable.groovy
on startup in order to more easily edit our test cases?
Thanks in advance!