-
Notifications
You must be signed in to change notification settings - Fork 146
Specify Environment Variables in RunSettings RFC #202
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # 0027 Specifying Environment Variables In RunSettings File | ||
|
|
||
| ## Summary | ||
| Specifying environment variables in the runsettings file. The environment variables can be set which can directly interact with the test host. | ||
|
|
||
| ## Motivation | ||
| Specifying environment variables in the runsettings file is necessary to support non-trivial projects that require settings env vars like DOTNET_ROOT. These variables are set while spawning the test host process, thus will be available in the host. | ||
|
|
||
| ## Usage | ||
| The runsettings contains a "EnvironmentVariables" node in the RunConfiguration section. | ||
| The different environment variables can be specified as element name and it's value. | ||
| Below is a sample runsettings for passing environment variables. | ||
|
|
||
| ```csharp | ||
|
|
||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- File name extension must be .runsettings --> | ||
| <RunSettings> | ||
| <RunConfiguration> | ||
| <EnvironmentVariables> | ||
| <!-- List of environment variables we want to set--> | ||
| <DOTNET_ROOT>C:\ProgramFiles\dotnet</DOTNET_ROOT> | ||
| <SDK_PATH>C:\Codebase\Sdk</SDK_PATH> | ||
| </EnvironmentVariables> | ||
| </RunConfiguration> | ||
| </RunSettings> | ||
|
|
||
|
|
||
| ``` | ||
| Since these environment variables should always be set when the test host is started, the tests should always run in a separate process. | ||
| For this, the `/InIsolation` flag will be set when there are environment variables so that the test host is always invoked. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense to not set the InIsolation flag when env vars are set as others who aren't running in isolation want to use this feature as well, not for the testhost invocation but inside the test app.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In certain specific cases, we run the tests inside vstest.console process without starting the testhost process. Since we are planning to set the environment variables when starting the test host, these cases will not be encountered for. This flag will insure that the test host is launched with the correct variables.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we support both cases?
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: do you usually use plural or singular? I.e. you have
RunSettings(plural) but alsoRunConfiguration(singular).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the
EnvironmentVariables, it made sense to use plural to infer that multiple values are allowed.