This guide will help you set up a test assembly so that it can be executed in different environments, using different values. This need often arises when a test assembly needs to be deployed from a test creator’s computer to a server or to an integration environment.
We’ll assume that you are using the test assembly from the Comparing Balances and Totals Between Two Tables for this. The steps are similar for any assembly, though.
Step 1: First, identify the items that you want to parameterize. The most likely candidates are connection or file assets, as these contain values that point to specific locations. In the example test assembly, you’ll want to parameterize the HigherEd and HigherEdDW connection assets.
Step 2: Open up the test suite’s Parameters page. Then, configure a parameter named
Repeat the process for the HigherEdDW connection, using a parameter name of HigherEdDWConnection.
Step 3: Build the project (Build > Build Solution or use the F6 key). This will update the .legitestsettings file associated
Step 4: Now, when the test is executed, the values specified in the .legitestsettings file will be used instead of the direct values specified on the ConnectionString properties.
Please note that if the parameter value is empty or includes whitespace, the directly specified value will still be used.
Step 5: Inside the development environment, you can view the .legitestsettings file in the related output folder for the test suite. After a build, you can also find the .legitestsettings file in the BIN folder.
Step 6: When tests are run, SentryOne Test will look for .legitestsettings files in the following locations, in order of priority:
c. The folder where the test assembly is located
Step 7: Any parameters with mappings to the test suite found in those locations will be applied to the test assembly. Parameters can also be used without mappings. This can be used if you want to alter only a portion of
1. Add a parameter named ServerName, and give it an appropriate value, such as (local).
2. In the connection string property, specify the connection string as:
3. At runtime, the value will be replaced with the value in the .legitestsettings file for the ServerName parameter.
Finally, in some cases, you might want to use environment variables to drive these changing values, without having to use a .legitestsettings file. In that case, you can use the following syntax when specifying the property value, and LegiTest will replace it with the referenced environment variable’s value:
Parameters are a useful way to make your tests dynamic, particularly if you need to pass the values in from outside of the test assembly itself. They're particularly useful when supporting multiple environments, such as Development, Test, and Production.