lundi 5 août 2019

How to use environment variables in unit tests

I have got a method that I am trying to test which uses environment variables from my "local.settings.json"

private static string _environmentVar = Environment.GetEnvironmentVariable("envirnomentVarConfig");

public string MyMethod{
    var result = DoStuff(_envirnmentVar)
    return result;  
}

In my test I am calling this method and when debugging, I can see that _environmentVar is null.

Do I need to setup envirnomentVarConfig in the test? If so how?

Aucun commentaire:

Enregistrer un commentaire