Implementing data-driven coded UI Tests in Visual Studio 2010

Source: Internet
Author: User
Tags visual studio visual studio 2010

Typically, we want to repeat a test with a different data value. This "Data driven" is very easy in coded UI test. In this example, we created a coded UI test to verify that the two digits in the calculator were incremented. Now, let's see how we can turn a simple codedui test into a data-driven test.

1, first create the Coded UI test (create the Coded UI test) (refer to the previous instance);

Then create the dataset. Coded UI test supports multiple data sources. The dataset can be defined in a CSV (comma-separated value) file, an Excel worksheet, an XML file, a database table, or a test case on TFS. In the example, we will use the data CSV file (TESTDATA.CSV) with the following.

Add1 Add2 Sum
8 2 10
6 2 8
4 2 6

L Create a Testdata.csv file

"CSV" is the abbreviation for comma separated value (comma separated values), usually a plain text file that can be opened with Notepad. Open Excel, and copy the above data to Excel, select Menu | file | Save As, select CSV format, you can create a CSV file.

For each recording operation, VSTS can abstract it into a method that stores the actions in a static method in the UIMap.Designer.cs class. You can make any modifications to these methods, or you can add an input parameter to the method you want to enter.

2, add the data source to the Coded UI test (add the the data source binding in coded UI test).

1 Open vs Menu | Test view-> Windows-> test View, as shown in Figure 1.

Figure 1 Coded the UI test property to create a data connection

3 through the above operation, open the New Data Source wizard interface, create a data source. Select CSV file-> Click Next, as shown in Figure 2.

Figure 2 New Data Source Wizard

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.