Professional Documents
Culture Documents
Codedui - DDT
Codedui - DDT
I n g . G o n za l o A l b a - M C P
2013
Data-Driven Testing
Data-Driven testing is when you store test data (input, expected output, etc.) in some external storage (like: databases, spreadsheet, xml files, csv files, etc.) and then use that data iteratively in your tests when running them.
Data-Driven Tests
The data source is now available for you to use in this test method. You use TestContext.DataRow to access the current row of data from your data source. You can access each column using the following syntax: string paramVal = TestContext.DataRow["Input1"].ToString(); this.UIMap.EnterDataInfo.UITextInputText = TestContext.DataRow["Input1"].ToString();
Data-Driven Tests
CSV file: TestX.csv
Data-Driven Tests
Example:
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\TestX.csv", "TestX#csv", DataAccessMethod.Sequential), DeploymentItem("TestX.csv"), TestMethod] public void RecordedTest() { string paramVal = TestContext.DataRow["Values"].ToString(); string paramVa2 = TestContext.DataRow["Numbers"].ToString();
Questions?