In latest Visual Studio 2019, Test Runner ignores environmentVariables
configuration which would allow for instance configuration of ASPNETCORE_ENVIRONMENT
.
This would be beneficial for integration tests that in local environment use different appsettings (non-production).
For instance I would like to define following launchSettings.json:
{
"profiles": {
"SomeFancyNamespace.ProjectName.Integration.Tests": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
There was an related issue that was closed: https://github.com/aspnet/Tooling/issues/456
Any news on this? Seems like a reasonable request
Also interested in this. Would really like to see this feature
We are interested in this as well. Seems like something that a lot of us would like.
I'm also looking forward for the fix.
Very annoying issue, and nobody replies regarding updates :(
Also having this issue in .net core unit test projects. Whats the whole point of having the environment variables present in the property pages of a .net core unit test project when setting them does absolutely nothing.
They did not fix it with this request: https://github.com/aspnet/Tooling/issues/456
Also did not fix it with this request: https://github.com/Microsoft/vstest/issues/1831
The workaround in 1831 is not acceptable as it won't work well for redistributable libraries that you intend to unit test. Since Microsoft is pushing the environment variable way of configuration, it should be a first class citizen in unit test projects as well. Not just ASP .NET Core web application projects.
The only current way to do it is to manually read the test project's launchSettings.json
then manually set environment variables from its contents, as per https://stackoverflow.com/a/43951218/70345
It's a really s**tty way to do things and one that really should just be supported by the tooling, but for whatever reason Microsoft is uninterested in implementing it...
Most helpful comment
Also having this issue in .net core unit test projects. Whats the whole point of having the environment variables present in the property pages of a .net core unit test project when setting them does absolutely nothing.
They did not fix it with this request: https://github.com/aspnet/Tooling/issues/456
Also did not fix it with this request: https://github.com/Microsoft/vstest/issues/1831
The workaround in 1831 is not acceptable as it won't work well for redistributable libraries that you intend to unit test. Since Microsoft is pushing the environment variable way of configuration, it should be a first class citizen in unit test projects as well. Not just ASP .NET Core web application projects.