cancel
Showing results for 
Search instead for 
Did you mean: 

Setting TC wide variables that are globally available for all projects

SOLVED
Highlighted
Contributor

Setting TC wide variables that are globally available for all projects

Is there a way to set global variables for all of TC? Script Extension properties maybe?

 

The applications we're testing have paths to various folders. These folders will need to be accessed from many tests.

BUT the paths to those folders may change.

ex.

Path = "C:\folder\folder\Outgoing";

Path = "\\192.168.0.1\Outgoing"

Path = "C:folder\folder\differentfoldername\Outgoing"

 

This base directory (everything leading up to \Outgoing) can be found in the registry. No problem, got that handled.

 

Here's the code I'm currently using:

function SetInnovationsVariables()
{
    AssignPathVariable("ArchivePath","String","Archive");
    AssignPathVariable("OutgoingPath","String","Outgoing");
      
    Log.Message(ProjectSuite.Variables.OutgoingPath); 
}


function AssignPathVariable(variableName, variableType, folderName)
{
    if(!ProjectSuite.Variables.VariableExists(variableName))
      ProjectSuite.Variables.AddVariable(variableName,variableType);
    var path = GetCurrentDBPath() + "\\" + folderName + "\\";
    
    return path;    
}

Function AssignPathPariables will get the current db base path and stick the folder name I want on the end. 

When I calll that function from SetInnovationsVariables, I would expect it to set the variable, but it doesn't.

 

It logs the correct path, but it's not available for any other project.

 

The problem is, setting these things as persistant global variables in a project suite. I've read all the posts/documentation and I still don't how you set these thing.

 

I set them in my project via the projectsuite (or project level) and they just don't persist. Frankly I'm tired of playing with it and I just want to make them available everywhere. 

 

Any suggestions on how to best do this? If anyone can explain how to set these to be persistant and projectsuite level that'd be great too because I'm just not getting it.

 

The variables are being created as persitant, but not set as persistant...??

 notpersistant.PNG

 

Thanks,

Rob

 

2 REPLIES
Community Hero

Re: Setting TC wide variables that are globally available for all projects

Hi Rob,

 

Yes, Project or ProjectSuite variables are global for the whole project or project suite respectively.

They can be either persistent or temporary. Both of them can be assigned values to, but the former persists assigned value into the project file (and thus the value is preserved between test runs) while the latter does not persist. Note, that as persistent variable saves its value into the project file, the file is marked as changed by OS and you may be getting notifications from OS and version control system about changed source file.

 

The values of your project suite variables do not change because a new value is not assigned to them.

One possible modification of your code:

function SetInnovationsVariables()
{
    ProjectSuite.Variables.ArchivePath = AssignPathVariable("ArchivePath","String","Archive");
    ProjectSuite.Variables.OutgoingPath = AssignPathVariable("OutgoingPath","String","Outgoing");
      
    Log.Message(ProjectSuite.Variables.OutgoingPath); 
}

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Contributor

Re: Setting TC wide variables that are globally available for all projects

That fixed it.

 

You are the best!

 

Share Your Stories
Read Latest News
Top Kudoed Authors