There are many guides on how to process data from encoded user interfaces on the Internet. The main steps for managing data with a CSV file are as follows.
- Create a CSV file.
- Add the CSV file to the project.
- Make sure the CSV file is deployed.
- Add the CSV file as a data source for a separate test.
- Read the CSV fields and use them in the test.
Detailed instructions with some options are described below.
Visual Studio 2010 has a “data source wizard” that performs some of these steps. In versions of Visual Studio 2012 and 2013 there is no wizard, so all steps must be performed manually.
Create CSV File
- , , . - . . (BOM) , CSV, , , . . .
CSV
, → . . , , , *.* *.csv.
, CSV
CSV . " " " , " " ". " , ", " ", , . - , , . , , , , .
CSV
[TestMethod] . Microsoft . CSV:
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV",
"|DataDirectory|\\data.csv", "data#csv",
DataAccessMethod.Sequential), DeploymentItem("data.csv"),
TestMethod]
, , #, .. Datasource(...), , , CSV.
|DataDirectory| , . , .
CSV
, , . ...Params, assert ...ExpectedValues, ... - . - , . action assertion. TestContext.DataRow[...].
, Coded UI test EnterValue, , CheckResult, . .
[DataSource...
TestMethod]
public void CodedUITestMethod1()
{
this.UIMap.EnterValueParams.UIItem0TextSendKeys = TestContext.DataRow["ValueOne"].ToString();
this.UIMap.EnterValueParams.UIItem1TextSendKeys = TestContext.DataRow["ValueTwo"].ToString();
this.UIMap.EnterValue();
this.UIMap.CheckResultExpectedValues.UIItem0TextDisplayText = TestContext.DataRow["Result"].ToString();
this.UIMap.CheckResult();
}
...Params ...ExpectedValues . , EnterValue , :
this.UIMap.EnterValueParams.UIItem2TextSendKeys = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");