I am trying to get rid of the .runsettings
file which I have in my project repo and keep all my config variables in a single .env
file.
The one place where I am stuck in is in the scenario when running tests through VS Code. I am writing C# and using the C# Dev Kit / C# extensions (Linux OS). There extensions automatically detect the NUnit tests and display them in the tests window. I can click the “Run Tests” and all the tests are executed. The problem is that the only way I found how to supply environment variables to these test runs is setting the dotnet.unitTests.runSettingsPath
configuration option to the location of the .runsettings
file. I dont want to keep this .runsettings
file around just for this one functionality. How can I tell VS Code to load the environment variables from a .env file when I trigger the “Run Tests” functionality.
Just in case anyone asks, I do not have a special task in my tasks.json or special entry in my launch.json files for the test run. It looks like VS Code is smart enough to automatically figure out how to find, load and run the tests in my project.