Dewey Vozel
Dewey Vozel

Reputation: 2413

Ability to Configure Environment Variables for Unit Tests (Specifically xUnit) in Rider

I have an xUnit project which from the IDE I run using the Unit Tests window or the run configuration All tests from Solution.

When configuring the All tests from Solution run configuration (or creating a new configuration), the name is the only configurable field and there is no way to specify environment variables. I'm using the Generic Host pattern to configure and expose my dependency injected resources. I need multi-environment support either through launchSettings or environment variables to configure the HostingEnvironment so different configurations can be tested, but there doesn't seem to be this capability in Rider. I think based on some search results I saw when searching on the problem that Visual Studio provides this capability for running xUnit / Unit Test projects.

This forum post is old but about the same / similar problem and one of the comments links to this youtrack issue which is marked fixed but then neither comments on that issue nor the comments on any of it's related "fixed" issues say how it was fixed or what the acceptable workaround is.

Upvotes: 2

Views: 4294

Answers (2)

Thick_propheT
Thick_propheT

Reputation: 1060

I too have been researching this sort of support in Rider. So far I've found that in

Tests > Unit Testing Settings... > Test Runner > Test Settings

You can specify a .runsettings file that will allow you to set Environment Variables via configuration for unit tests.

I haven't yet found a way to switch them out easily nor a way to have them auto detected (so you can just commit it to your repository and have it automatically detected for everyone's test runs), but I'll try to remember to come leave an update here when or if I do figure out those details.

Upvotes: 0

Ivan Shakhov
Ivan Shakhov

Reputation: 1425

File | Settings | Build, Execution, Deployment | Unit Testing | Test Runner

Upvotes: 1

Related Questions