Forum Discussion
Hi Guys,
I am using project temporary variable Var1 with default value "Default".
I have a project suit with two tests - Test1 and Test2. Test1 is executed first and then next test item is Test2.
In Test1 i set the Var1 to "NewValue". When I ran my test suite and use the value of Var1 in my second test item "Test2" it's still "NewValue".
According to the above post Var1 should be with its default value "Default" since it is a Temporary variable and should not persist during the instances of different test items.
Please correct me if I am wrong.
Kind Regards
ATQC Kaloyan Chipilev
Unfortunately, you do happen to be incorrect. The "temporary" designation for temporary project variables has to do with whether or not the value of the variable persists between test runs. So, you have a project... while running the project, you set the value of the variable. So long as the project is running, that value persists unless it is changed. When the project stops running, the value is cleared and the variable is reset to default.
Think of it as such:
var tempVariable = 'default';
function test1() {
Log.Message(tempVariable);
tempVariable = 'my test';
Log.Message(tempVariable);
}
function test2(){
Log.Message(tempVariable);
}
function foo() {
test1();
test2();
}
When you run function foo, the output should show in the log as
default <- The log message before the variable value is set
my test <- The log message in test1 after the variable value is set
my test <- The log message in test2
If you rerun function foo, you'll get the same output.
Think of "foo" as your project and "tempVariable" as your temporary project variable.
- Kaloyan9 years agoOccasional Contributor
Thank you very much for the explanation , now i got it.