How do I instantiate a Project Variable at the Test level?
- 9 years ago
Actually, I think I might know what's up...
What I did is created a new persistant project variable called "foo" with a default value of "bar"Notice that the local value is blank.
If I create a Keyword test now with out first setting the value of foo and tell it to log a message using the "foo" variable, I get a blank message.If I first populate "foo" with a Local Value, then run the same keyword test, the message now contains that local value...
Now... this is different than if I create a TEMPORARY project variable with a default value. Then, no matter what, if I don't first assign a value to the variable, I'll get the default value.
That's the difference between persistent and temporary. Persistant variables store the values assigned to them during a test and persist those values even after the test run is complete. Temporary variables values are initialized by the default but will vary during the test run and will not persist after the run is complete.
So... the question is... which are you using? If you're using a Persistant variable and are not setting a local value before you try to use it, you will get nothing unless you explicitly set the value using some sort of expression (as per bbi). However, if you are using a temporary variable with a default value, then you will not need to use some special assignment to first initialize the variable before you use it.