Unit Test Runner has now capability to inject environment variables
Starting with the next minor update v2011 vol2.8, the Unit Test Runner supports injection of environment variables for 3rd-party tools. Third-party tools may require providing the CodeRush Unit Test Runner with some environment variables for proper execution when launching the Test Runner process.
To add environment variables into the Unit Test Runner, you can use one of the two approaches:
1. Dynamic initialization of environment variables
You have to create a new DXCore plug-in and subscribe to the SetupExternalProcess event of the UnitTests DXCore service. This event fires when the Unit Test Runner external process is going to start. In the event handler you can add required environment variables as follows:
public partial class EnvironmentVariablesSamplePlugIn : StandardPlugIn { public override void InitializePlugIn() { base.InitializePlugIn(); CodeRush.UnitTests.SetupExternalProcess += UnitTests_SetupExternalProcess; } public override void FinalizePlugIn() { CodeRush.UnitTests.SetupExternalProcess -= UnitTests_SetupExternalProcess; base.FinalizePlugIn(); } void UnitTests_SetupExternalProcess(ExternalRunnerArgs args) { args.AddEnvironment("VariableName", "VariableValue"); } }
Mind that with this approach your plug-in must be loaded at DXCore start-up. Don’t forget to set the corresponding property inside the AssemblyInfo.cs or when creating a plug-in.
2. Permanent initialization of environment variables
You can also add required variables to the Unit Test Runner via the *.config files of the Test Runner executable. Using this approach environment variables will be stored permanently.
Configuration files are located inside the CodeRush plug-ins folder for each executable (for .NET 4.0, x64, etc):
%ProgramFiles%\DevExpress %version%\IDETools\System\CodeRush\BIN\PLUGINS\
To pass necessary environment variables, add them to the “appsettings” section of the configuration file and then check these values in your code to enable or disable certain features:
<configuration> <appsettings> <environment name="EnvVariableName1" value="VarValue1" /> <environment name="EnvVariableName2" value="VarValue2" /> </appsettings> </configuration>
See additional details in the S139197 report.
—– Products: CodeRush Pro Versions: 11.2.8 and up VS IDEs: 2008 and up Updated: Jan/26/2012 ID: U001Similar Posts:
- Support for XUnit, NUnit, MBUnit, and Visual Studio testing frameworks
- Code Generation – Create Descendant and Create Descendant (with virtual overrides)
- How to load stored settings from an Options page inside of a plug-in
- DXCore adornments creation and wizards
- Silverlight testing framework support in the Unit Testing Service