I am using Microsoft's WinAppDriver in conjunction with Visual Studio 2015 unit tests to automate testing of Windows applications. These tests are being run from the command line using VSTest.exe because I can pass a .runsettings file as a parameter to specify certain test settings that I may have to change in the future. I want to be able to reference the .runsettings file directly from my test methods without needing to create a bunch of global variables at the beginning of my code in the Setup method. Although I am using multiple classes, I am more or less doing it like so:
protected static string basicFile;
[ClassInitialize]
public static void Setup(TestContext context)
{
var basicFile = context.Properties["basic"].ToString();
}
[TestMethod]
public void BasicTest(){
OpenFile(basicFile);
}
Where context.Properties[] references the key in my .runsettings file.
The reason I cannot simply do
[TestMethod]
public void BasicTest(TestContext context){
var basicFile = context.Properties["basic"].ToString();
OpenFile(basicFile);
}
is because test methods cannot accept any parameters. So, is there any way I can directly reference the .runsettings file within the test method without using context.Properties?