Using Environment Variables

Environment variables are names that each have an associated string; they are managed by the operating system. For example, the "path" environment variable has a string associated with it that contains all of the folders to search for executable files.

Environment variables may be used in all LiveCoverage file and folder names. You can use the name of an environment variable within the file or folder name, and the associated string will be substituted for that name whenever it is used. A LiveCoverage project stores the file name with the environment variable name it in, so it can then be expanded to a potentially different name on each computer that the project is used on. This allows you to use the same project file on machines with different file system layouts.

You use an environment variable name by bracketing it with percent characters ("%") within the LiveCoverage file name string. If a non-existent environment variable is used, the name will be replaced with an empty string.

Example

Suppose you have a software development project with a subfolder named bin that contains the executable files. You want to segregate LiveCoverage test results by operating system, so they will go in a subfolder of the results folder named win98 or winnt, depending on the OS of the machine doing the testing.

You might have each machine that will run tests define environment variables called ProjDir and OsDir. Then to test an executable file named ourprog.exe, you could give LiveCoverage these file names:

Executable File

%ProjDir%\bin\ourprog.exe

Coverage File

%ProjDir%\results\%OsDir%\ourprog.lcb

If you have a machine with these environment variable settings:

set ProjDir=d:\projects\version1
set OsDir=win98

Then these file names will expand to:

Executable File

d:\projects\version1\bin\ourprog.exe

Coverage File

d:\projects\version1\results\win98\ourprog.lcb