[5.8.0] GlobalVariable of type null is not allowed, no longer store instances of user defined class


#1

OS: Windows7
Katalon version: 5.8.0
Browser: Firefox 62.0.3
Katalon log: attached but not relevant

What was possible in 5.7.x

In 5.7.x, I could choose Null as the type of a GlobalVariable in Profile. See the screenshot:


In the ./Libs/internal/GlobalVariable.groovy file I found the GlobalVariable.MATERIAL_REPOSITORY had the initial value of null.

    static {
        def allVariables = [:]        
        allVariables.put('default', ['CURRENT_TESTCASE_ID' : '',             'MATERIAL_REPOSITORY' : null,            'Hostname' : 'demoaut.katalon.com', 'Username' : 'John Doe', 'Password' : 'ThisIsNotAPassword'])
        allVariables.put('develop', allVariables['default'] + ['CURRENT_TESTCASE_ID' : '',            'MATERIAL_REPOSITORY' : null,             'Hostname' : 'demoaut-mimic.kazurayam.com', 'Username' : 'John Doe', 'Password' : 'ThisIsNotAPassword'])
        allVariables.put('product', allVariables['default'] + ['CURRENT_TESTCASE_ID' : '',             'MATERIAL_REPOSITORY' : null,            'Hostname' : 'demoaut.katalon.com', 'Username' : 'John Doe', 'Password' : 'ThisIsNotAPassword'])

In a Test Listener of my “Visual Testing in Katalon Studio” project, I have a code as follows:

@BeforeTestCase
def beforeTestCase(TestCaseContext testCaseContext) {
    if (GlobalVariable.MATERIAL_REPOSITORY == null) {
        MaterialRepository mr = MaterialRepositoryFactory.createInstance(materialsFolder)
        GlobalVariable.MATERIAL_REPOSITORY = mr
    }
    GlobalVariable.CURRENT_TESTCASE_ID = testCaseContext.getTestCaseId()   //  e.g. 'Test Cases/TC1'
}

This worked fine with Katalon Studio 5.7.x

What happend in 5.8.0

In Katalon 5.8.0, I can not select Null as the type of a GlobalVariable any longer. The option Null is not available. See the screenshot:

Because I could not select Null for GlobalVariable.MATERIALS_REPOSITORY in a new Profile “google.co.jp”, I alternatively assigned String type for it. I found in the source code I noticed the GlobalVariable.MATERIALS_REPOSITORY has the initial value ‘’ of String type.

    static {        def allVariables = [:]        
        allVariables.put('default', ['CURRENT_TESTCASE_ID' : '', 'MATERIAL_REPOSITORY' : null, 'Hostname' : 'demoaut.katalon.com', 'Username' : 'John Doe', 'Password' : 'ThisIsNotAPassword'])
        allVariables.put('google.co.jp', allVariables['default'] + [            'MATERIAL_REPOSITORY' : '',             'CURRENT_TESTCASE_ID' : '', 'URL' : 'https://www.google.co.jp/ncr'])
        allVariables.put('google.com', allVariables['default'] + [            'MATERIAL_REPOSITORY' : null,            'CURRENT_TESTCASE_ID' : '', 'URL' : 'https://www.google.com/ncr'])
        

When I runt the Test, I got the following error:

Test Cases/StepByStep/TC_step4 - parameterized URL FAILED because (of) (  Stack trace: org.codehaus.groovy.runtime.typehandling.GroovyCastException:     Cannot cast object '' with class 'java.lang.String'       to class 'com.kazurayam.materials.MaterialRepository'	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:405)

It seems that the org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM() does not like substituting my instance of com.kazurayam.materials.MaterialRepository class into a internal.GlobalVariable with initial type of java.lang.String.

How significant is this issue?

Until v5.7.1 I could store any type of Java/Groovy object into a GlobalVariable with initial type of Null. I depend heavily on this technique. I use this technique in the following projects of mine.

  1. https://forum.katalon.com/discussion/9799/visual-testing-in-katalon-studio

  2. https://forum.katalon.com/discussion/9407/how-multiple-test-cases-in-a-test-suite-safely-write-data-into-an-excel-file

  3. https://forum.katalon.com/discussion/10208/testing-youtube-video-in-katalon-studio

  4. https://forum.katalon.com/discussion/10193/testing-slideshow-in-katalon-studio

and more.

Conclusion

Now in KS5.8.0, GlobalVariable of type Null is gone. Therefore you can not save instances of user-defined classes into GlobalVariable any longer.

I miss GlobalVariable of type Null very much. I can not use KS5.8.0 at all due to this restriction.

I hope Katalon Team to bring GlobalVariable of type Null available again.

.log

GlobalVariable_of_type_Null_was_possible_in_5.7.x.png

GlobalVariable_of_type_Null_is_no_possible_any_longer.png


Multiple Test Cases in a Test Suite can share a Excel file to read/write data dynamically
#2

I have found a possible workaround in KS 5.8.0 and higher.

  1. Declare GlobalVariable.MATERIAL_REPOSITORY as type String.

  2. With text editor of your choice (not Katlaon Studio), open /Profile/.glbl file

  3. In the *.glbl, find a section

    <GlobalVariableEntity>      <description></description>      <initValue>''</initValue>      <name>MATERIAL_REPOSITORY</name>   </GlobalVariableEntity>
    
  4. Edit it as

    <GlobalVariableEntity>      <description></description>      <initValue>null</initValue>      <name>MATERIAL_REPOSITORY</name>   </GlobalVariableEntity>
    
  5. save the file

  6. reopen the project in Katalon Studio


#3

We’ve brought back it in 5.8.4 version. Sorry for inconveniences we’ve caused regard to this change.


#4

I have confirmed it. Thank you very much.

Please close this topic.