Search code examples
asp.net-coreconfigurationspecflow

Specflow: How to configure environment variables


I would like to configure environment variables like connection strings for my specflow tests in such a way that my tests should use my appsettings locally and use the values from keyvaults/pipeline environment variables while running in pipeline.I would like to achieve this without specifying any AddJsonFile. Any leads would be appreciated. Thanks.


Solution

  • You can set EnvironmentVariable:

    Environment.SetEnvironmentVariable("lorem", "ipsum");
    

    Environment.SetEnvironmentVariable Method

    Creates, modifies, or deletes an environment variable stored in the current process.