This topic describes how to configure and work with different environments. In this section: Environments are collections of variables that can be referenced within fields of your responder or action suite.You can use environment variables to specify endpoints, database table names, connection properties, such as login credentials, and so on. The names of variables will be substituted with the assigned values in the active environment. By switching which environment is the "active" environment, you can dynamically switch the environment-specific values at runtime. Environments can also be used to switch virtual asset modes. For example, assume you configured a responder to forward traffic to an external endpoint. By using an environment variable for the endpoint (instead of a fixed value), you can easily redirect message forwarding to different endpoints. This allows .pva files to act like proxies; one environment can point to a real asset while another points to a virtual asset. Environments are automatically defined when you generate a Parasoft asset from a definition, such as WSDL, but you can also manually define environments as described below. Creating and switching environments is done through the Environments branch of the Responder suite’s Virtual Asset Explorer node. The Environments branch is created by default when a new Responder suite is created. You can right-click on a variable and choose Mask Variable Value to hide the value in the interface. Using Environment Variables in Tests and Tools Environment variables can be accessed in test or tool configuration fields using a special syntax. To reference a variable, enclose the variable name in the following character sequence: For example, if you had a variable named HOST, you would reference the variable in a field by typing: Note To change what environment is active, right-click the node representing the environment you want to make active, then choose Set as Active Environment. You may find that many configuration settings, such as server names and ports, will be common across multiple projects. Rather than duplicating these settings, you can export environment settings to an external file and import or reference the values in other projects. To export an environment: The environments configuration will be written in an XML-based text file. If one Environment is selected, a When you import environments, you are bringing a copy of the values from the external environment file into your project. Further modification to the XML file will not be reflected in your project. To import an environment: Referencing environments is the most efficient way to share a single environment configuration across multiple projects. Using environment references, you can easily modify the configurations of multiple projects from a single location. To reference an environment: Note that when an environment configuration is referenced, you cannot edit the environment variables in the environment directly. However, your project will always use the values reflected in the referenced Environment (.env) files are XML-based text files and can be edited manually. It is not recommended that you try to create an .env file from scratch; instead, export an environment as described in Exporting an Environment to use as a template. After exporting an environment, you can open it in any text editor to make changes. It will look similar to the sample below. Existing variables can be edited directly. To add a new variable, copy an existing variable (everything between a set of <Variable></Variable> tags, including those tags) and paste on a new line, then change the name and value as needed. Note that masked values should not be modified manually, nor should you attempt to create a masked value manually; work with masked values in the UI only.Understanding Environments
Manually Defining an Environment
Masking a Variable Value
${env_name}
.${HOST}
. Variable references may appear anywhere within a field.You can access Environment Variable values from an Extension Tool/Script through the Extensibility API. ExtensionToolContext now has a method called "getEnvironmentVariableValue(String)
" which will look up and return the current value of an Environment variable. This will allow you to use the value within your scripts.${}
, you can escape the sequence by adding a backslash. For example, if SOAtest or Virtualize encounters the value "\${HOST}
" it will use the value "${HOST}
" and will not try to resolve the variable. Also note that environment variable names are case sensitive.Changing Environments from the GUI
Exporting, Importing, Referencing, and Editing Environments
Exporting Environments
*.env
file will be created, containing a single environment. If multiple environments are selected, an *.envs
, or Environment Set, file will be created containing all of the selected environments.Importing Environments
Referencing Environments
*.env
file. Modifying the *.env
file will propagate changes to all projects that reference it.Editing Environment (.env) Files
<?xml version="1.0" encoding="UTF-8"?>
<Environment xmlns="http://www.parasoft.com/schema/environment/1.0"
name="New Environment">
<Variable>
<Name>Name1</Name>
<Value mask="false">Value1</Value>
</Variable>
<Variable>
<Name>Name2</Name>
<Value mask="false">Value2</Value>
</Variable>
</Environment>
If your test case or tool requires the character sequence
Sample .env XML
Overview
Content Tools