Can I Declare Custom Type for GlobalVariableEntity in Execution Profile?

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.

  1. 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.

  2. 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!

It seems I can’t edit my original post anymore, so I thought I should post a clarification

What I want:

...
public class GlobalVariable {
     
    /**
     * <p>Profile default : I want to set this variable type</p>
     */
    public static MyCustomType customObject

...

Current Behavior:

...
public class GlobalVariable {
     
    /**
     * <p>Profile default : I want to set this variable type</p>
     */
    public static Object customObject

...

To create a custom data type, complete the following steps:

Create a local configuration file that has the .ini file name extension, such as localwpp.ini. You cannot add a custom type to a header or source file.

Use the TYPEMACRO constant to define the custom data type.

Identify the configuration data in your sources or header file.

Add the -ini parameter to the RUN_WPP macro in your source file.

Use the custom data type in trace messages.

Thank you so much for your response! Would there be any way to do this on a project level, so the solution could be shared via version control?