Using DataManager

Feb 20, 2014 at 7:38 PM
Hi,

I wish to use DataManager for data-driven testing. I have created a data file as below:
<?xml version="1.0" encoding="utf-8" ?>
<data>
  <datarow id="credentials">
    <username>myUserName</username>
    <password>myPassword</password>
  </datarow>
  <datarow id="Url_1" inherits="credentials">
    <url>www.gmail.com</url>
  </datarow>
  <datarow id="Url_2" inherits="credentials">
    <url>www.yahoo.com</url>
  </datarow>
</data>
How can use DataManager in my CUITe based test so that it can go through each datarow (except the first one) and performs the test operations.

Thanks in advance,
Kay
Coordinator
Mar 7, 2014 at 6:53 AM
Hi Kay,

You can see a unit test that provides example code which retrieves values in the XML file here.
        [TestMethod]
        public void DataManager_GetDataRowUsingEmbeddedResource_Succeeds()
        {
            AssertGetDataRowHashtableFromEmbeddedResourceExpectedValues(typeof(HtmlControlTests));
        }

        private void AssertGetDataRowHashtableFromEmbeddedResourceExpectedValues(Type type)
        {
            Hashtable ht = CUITe.CUITe_DataManager.GetDataRow(type, "XMLFile1.xml", "tc2");
            Assert.AreEqual("test", ht["test"]);
            Assert.AreEqual("Kondapur, Hyderabad", ht["address"]);
            Assert.AreEqual("Suresh", ht["firstname"]);
            Assert.AreEqual("Balasubramanian", ht["lastname"]);
            Assert.AreEqual("04/19/1973", ht["dob"]);
            Assert.AreEqual("37", ht["age"]);
            Assert.AreEqual("Indian", ht["nationality"]);
        }
Marked as answer by Ksaxena on 4/1/2014 at 12:30 PM
Sep 9, 2014 at 2:20 PM
Is it possible for the data source to be an excel file, rather than an xml? If so, do you have an example code snippet?

Thanks.