PremKumarKatta
PremKumarKatta

Reputation: 3

running coded UI automation test multiple times

i have created an automated testing using coded UI automation(by recording actions). i need to run the test multiple times using data driven test, connection string to XML document. this needs to be run based on a number i give as input, this number needs to be incremented each time. is this possible in coded UI automation testing? any other suggestions?

Upvotes: 0

Views: 1494

Answers (1)

chaliasos
chaliasos

Reputation: 9783

All you need is to create a CodedUI Data-driven Test.

In the DataSource attribut set the DataAccessMethod as DataAccessMethod.Sequential so your test will read all data rows and execute them in the their order one at the time.

You also need to use the DeploymentAttribute so your xml file will be deployed to the output folder.

Example:

[DeploymentItem("data.xml")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "\\data.xml", "Iterations", DataAccessMethod.Sequential)]
[TestMethod]
public void CodedUITestMethod1()
{
    // To generate code for this test, select "Generate Code for 
    // Coded UI Test" from the shortcut menu and select one of 
    // the menu items.
    this.UIMap.AddTwoNumbersParams.TextInput1EditText = 
        TestContext.DataRow["Input1"].ToString();
    this.UIMap.AddTwoNumbersParams.TextInput2EditText = 
        TestContext.DataRow["Input2"].ToString();
    this.UIMap.AddTwoNumbers();

    this.UIMap.AssertforAddExpectedValues.TextAnswerEditText = 
        TestContext.DataRow["ExpectedResult"].ToString();
    this.UIMap.AssertforAdd();
}

Upvotes: 1

Related Questions