every time i put a new value for the same GlobalVariable, i must run my testcase twice to make the new value taking effect
do you know why ??
I can answer to this question.
To understand my answer, please know what the ./Libs/internal/GlobalVariable.groovy file is. All Katalon Studio projects has this file. This file is auto-generated by Katalon Studio. The content of the file is a Groovy script, like this:
package internal
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.main.TestCaseMain
/**
* This class is generated automatically by Katalon Studio and should not be modified or deleted.
*/
public class GlobalVariable {
/**
* <p></p>
*/
public static Object config
static {
try {
def selectedVariables = TestCaseMain.getGlobalVariables("default")
selectedVariables += TestCaseMain.getGlobalVariables(RunConfiguration.getExecutionProfile())
selectedVariables += TestCaseMain.getParsedValues(RunConfiguration.getOverridingParameters())
config = selectedVariables['config']
} catch (Exception e) {
TestCaseMain.logGlobalVariableError(e)
}
}
}
Then, see the following diagram.
I will dictate this diagram.
step 0
- Let’s begin; a tester opens a Katalon project.
- Katalon Studio will generate the
./Libs/internal/GlobalVariable.groovyon the startup of the project.
step 1
- A test opens “edit Execution Profile” UI. It will load the
./Profiles/default.glblXML file and will show how it is written. - He will edit the profile and edit the value of
GlobalVariable.foo. - The UI will serialize the profile into the
default.glblfile. - He runs a Test Case
TC1 - The
GlobalVariable.groovyscript will be compiled and run. - The
GlobalVariableclass load the XML files; now TC1 can refer to the values such asGlobalVariable.foo.
step 2
Here I assume we have another Test Case named TC2, which is capable of changing the XML file using the GlobalVariableUpderter class.
- The tester runs
TC2 - The
TC2updates the XML file - When the XML file is updated, no notification will be sent to the “edit Execution Profile” UI.
- Therefore the “edit Execution Profile” UI will show no change. Old values will remain displayed.
step 3
- The tester runs
TC1again - The updated XML will be loaded and referred to.
- But the tester still finds the old data in the “edit Execution Profile” UI.
step 4
- The tester closes the project.
- When he reopen the project, he will go back tot the step 0.
Discussion
Here I tried the GlobalVariableUpdater class to update GlobalVariable values runtime. It works fine except a point that the “edit Execution Profile” UI will be left un-updated. People would expect the GUI always shows the truth, but it wouldn’t this case.
If a tester operates the “edit Execption Profile”, for example, switching the profile to display, then the UI would be refreshed with the latest XML; then he would see the updated value. He might be confused to see the change at an unexpected timing. This way, I suppose, @mtayashi was confused.
