I have recently moved to .net 5 and finding difficulty in reading settings.json file. The settings.json file is being searched in test results folder rather than in the main folder.
I have tried this as well but did not help.
I store all urls and other data in a settings.json file
And also have an another file to read data from settings.json file like below :
public static class SettingsUtil
public static T GetObjectFromJsonFile<T>(string filename)
string json = File.ReadAllText(filename);
var deserializedObject = JsonConvert.DeserializeObject<T>(json);
And in each of the step defnition file where I need data from settings.json file, I use this
private readonly Settings settings;
settings = SettingsUtil.GetObjectFromJsonFile<Settings>("settings.json");
So, my issue here is, when I try to read the settings.json file in string json = File.ReadAllText(filename); , it is searching settings.json file in another folder(Test results folder) than the main folder(SpecFlowProjectSample) where my project exists.
This works in mstest but not with specrunner.Could you help me in fixing this issue.
Please sign in to leave a comment.