Following the procedures outlines here and here I was able to set a TestRunParameter and access it at run time in a Unit test. I then repeated the exact same process in a coded UI test but am not able to access the Properties.
My .runsettings file:
<RunSettings>
<TestRunParameters>
<Parameter name="webAppUrl" value="http://localhost" />
</TestRunParameters>
</RunSettings>
My Test Method:
[TestMethod]
public void MyTest1()
{
// This throws an error because Properties["webAppUrl"] is null
string webAppUrl = TestContext.Properties["webAppUrl"].ToString();
// etc...
}
Does a Coded UI test need additional configuration to access these run time properties?
Edit:
I notice that within the context of a Unit test, the TestContext is Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestContextImplementation
. In the Coded UI test, the TestContext is Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapterContext
.