Forum Discussion

Lee_M's avatar
Lee_M
Community Hero
4 years ago

String Default Values

I have a persistent variable of type String

 

I have 'unset'/deleted the Local Value and then perform a KW log message on the variable

I expected to see the default value but instead, I see a blank value inserted into the local

 

Isn't the point of default values a fallback ?

  • Hi,

     

    What is the point of having a default value then?
    The roots of this functionality are back to the projects opened in a Shared Mode. Unfortunately, this extremely useful functionality is broken for several years (major TestComplete versions) and I barely hope it will be restored (Case #00126077)

    When a project was opened in a shared mode, all its project variables became per-computer personalized. I.e. if you open your test project in the shared mode from box A, the value of the dataPath project variable could be c:\testData\ but if you open the same project from box B, the value of the same variable could be d:\dataForMyTests\.

    In the above scenario, when the project was opened in the shared mode for the first time on the given box, all project variables got their local values from default ones. So in this case default value of the project variable had exactly that meaning that you are expecting.

    Unfortunately, as I said, the above scenario with its extensions like customized set of enabled Test Items (that personally I widely used) does not work anymore and thus your version of reply ("It is like having a second variable value in this case") is much closer to reality. The only convenience is that you do not need to have separate variables for actual and default value but can have one variable that keeps both actual and default value.

     

    sonya_m : Just for your information. Case #00126077...

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Empty value is a valid one that project variable can contain and thus I see no reason for fallback to default.

    Use .GetVariableDefaultValue() method to get the default value of the variable.

     

    • Lee_M's avatar
      Lee_M
      Community Hero

      What is the point of having a default value then?
      It is like having a second variable value in this case

      I set up a string variable in the project and then test if a value has been entered during the run - I have to test every time for an empty string too now

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        What is the point of having a default value then?
        The roots of this functionality are back to the projects opened in a Shared Mode. Unfortunately, this extremely useful functionality is broken for several years (major TestComplete versions) and I barely hope it will be restored (Case #00126077)

        When a project was opened in a shared mode, all its project variables became per-computer personalized. I.e. if you open your test project in the shared mode from box A, the value of the dataPath project variable could be c:\testData\ but if you open the same project from box B, the value of the same variable could be d:\dataForMyTests\.

        In the above scenario, when the project was opened in the shared mode for the first time on the given box, all project variables got their local values from default ones. So in this case default value of the project variable had exactly that meaning that you are expecting.

        Unfortunately, as I said, the above scenario with its extensions like customized set of enabled Test Items (that personally I widely used) does not work anymore and thus your version of reply ("It is like having a second variable value in this case") is much closer to reality. The only convenience is that you do not need to have separate variables for actual and default value but can have one variable that keeps both actual and default value.

         

        sonya_m : Just for your information. Case #00126077...