Using MSTest, I needed to obtain the name of the current test from within the [TestInitialize] method. You can get this from the TestContext.TestName
Issue can be resolved like this:
First define a static property:
private static string _targetUrl;
Then assing the value from runsetting file inside the ClassInitialize type of method, Use TestContext as an input parameter.
[ClassInitialize]
public static void Initialize(TestContext testContext)
{
_targetUrl = testContext.Properties["targetUrl"].ToString();
}
Variable is initialized, ready to use it further.