I have a Test Method which is calling 2 Sub Test Methods. Both the sub Methods are Data Driven from an XML file. If I run each sub methods they run fine and successful. However, when I run Main Test Method (caller of both sub methods) it finds TestContext.DataConnection and TestContext.DataRow as null.
private TestContext testContext;
public TestContext TestContext
{
get { return testContext; }
set { testContext = value; }
}
[TestMethod]
public void SaveEmpty_Json_LocalStorage()
{
// Testing JSON Type format export and save
SetWindowsUsers();
// Add Network Information
SetWifiInformation();
// More logic and assertions here.
// More logic and assertions here.
// More logic and assertions here.
}
[TestMethod]
[DeploymentItem("input.xml")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML",
"input.xml",
"User",
DataAccessMethod.Sequential)]
public void SetWindowsUsers()
{
Console.WriteLine(TestContext.DataRow["UserName"].ToString())
// MORE LOGIC and Asserts
}
[TestMethod]
[DeploymentItem("input.xml")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML",
"input.xml",
"WifiList",
DataAccessMethod.Sequential)]
public void SetWifiInformation()
{
Console.WriteLine(TestContext.DataRow["SSID"].ToString())
// MORE LOGIC and Asserts
}
If I Run All, 2 Methods pass and 1 fails. If I run individually, SaveData_Json_LocalStorage Does not pass, always gets TestContext.DataRow as null. Is it okay to call multiple methods inside. What is best way of writing chained test cases.