Skip to content

Commit 51b0781

Browse files
authored
Merge pull request #2148 from gewarren/gewarren-coded-ui
Refresh coded UI test for UWP app topic
2 parents 3931a78 + 76b897c commit 51b0781

38 files changed

+308
-830
lines changed

.openpublishing.redirection.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,16 @@
20202020
"redirect_url": "/visualstudio/test/run-unit-tests-with-test-explorer",
20212021
"redirect_document_id": false
20222022
},
2023+
{
2024+
"source_path": "docs/test/test-windows-store-8-1-apps-with-coded-ui-tests.md",
2025+
"redirect_url": "/visualstudio/test/test-uwp-app-with-coded-ui-test",
2026+
"redirect_document_id": false
2027+
},
2028+
{
2029+
"source_path": "docs/test/test-windows-phone-8-1-apps-with-coded-ui-tests.md",
2030+
"redirect_url": "/visualstudio/test/test-uwp-app-with-coded-ui-test",
2031+
"redirect_document_id": false
2032+
},
20232033
{
20242034
"source_path": "docs/test/testing-store-apps-with-visual-studio.md",
20252035
"redirect_url": "/visualstudio/test/create-and-run-unit-tests-for-a-store-app-in-visual-studio/",

docs/test/creating-a-data-driven-coded-ui-test.md

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,27 @@ ms.date: 11/04/2016
44
ms.prod: visual-studio-dev15
55
ms.technology: vs-ide-test
66
ms.topic: conceptual
7-
helpviewer_keywords:
7+
helpviewer_keywords:
88
- "coded UI tests, data-driven"
99
author: gewarren
1010
ms.author: gewarren
1111
manager: douge
12-
ms.workload:
12+
ms.workload:
1313
- "multiple"
1414
---
15-
# Creating a Data-Driven Coded UI Test
15+
# Create a Data-Driven Coded UI Test
1616

1717
To test different conditions, you can run your tests multiple times with different parameter values. Data-driven coded UI tests are a convenient way to do this. You define parameter values in a data source, and each row in the data source is an iteration of the coded UI test. The overall result of the test will be based on the outcome for all the iterations. For example, if one test iteration fails, the overall test result is failure.
1818

19-
**Requirements**
19+
**Requirements**
2020

21-
- Visual Studio Enterprise
21+
- Visual Studio Enterprise
2222

2323
## Create a data-driven coded UI test
24-
This sample creates a coded UI test that runs on the Windows Calculator application. It adds two numbers together and uses an assertion to validate that the sum is correct. Next, the assertion and the parameter values for the two numbers are coded to become data-driven and stored in a comma-separated value (.csv) file.
2524

26-
#### Step 1 - Create a coded UI test
25+
This sample creates a coded UI test that runs on the Windows Calculator application. It adds two numbers together and uses an assertion to validate that the sum is correct. Next, the assertion and the parameter values for the two numbers are coded to become data-driven and stored in a comma-separated value (.csv) file.
26+
27+
### Step 1 - Create a coded UI test
2728

2829
1. Create a project.
2930

@@ -87,7 +88,7 @@ To test different conditions, you can run your tests multiple times with differe
8788

8889
At this point, all the parameter values are defined in their methods as constants. Next, let's create a data set to make our test data-driven.
8990

90-
#### Step 2 - Create a data set
91+
### Step 2 - Create a data set
9192

9293
1. Add a text file to the dataDrivenSample project named `data.csv`.
9394

@@ -113,7 +114,7 @@ To test different conditions, you can run your tests multiple times with differe
113114

114115
Now that we have the data set created, let's bind the data to the test.
115116

116-
#### Step 3 - Add data source binding
117+
### Step 3 - Add data source binding
117118

118119
1. To bind the data source, add a `DataSource` attribute within the existing `[TestMethod]` attribute that is immediately above the test method.
119120

@@ -140,7 +141,7 @@ To test different conditions, you can run your tests multiple times with differe
140141

141142
Next, we'll configure the test to use the values in the data source file.
142143

143-
#### Step 4 - Use the data in the coded UI test
144+
### Step 4 - Use the data in the coded UI test
144145

145146
1. Add `using Microsoft.VisualStudio.TestTools.UITesting.WinControls` to the top of the CodedUITest.cs file:
146147

@@ -189,7 +190,7 @@ To test different conditions, you can run your tests multiple times with differe
189190

190191
3. Save the solution.
191192

192-
#### Step 5 - Run the data-driven test
193+
### Step 5 - Run the data-driven test
193194

194195
1. Verify that the test is now data-driven by running the test again.
195196

@@ -202,9 +203,10 @@ To test different conditions, you can run your tests multiple times with differe
202203
## Q & A
203204

204205
### <a name="CreateDataDrivenCUIT_QA_DataSourceAttributes"></a> What are the data source attributes for other data source types, such as SQL Express or XML?
205-
You can use the sample data source strings in the table below by copying them to your code and making the necessary customizations.
206206

207-
**Data Source Types and Attributes**
207+
You can use the sample data source strings in the table below by copying them to your code and making the necessary customizations.
208+
209+
**Data Source Types and Attributes**
208210

209211
- CSV
210212

@@ -226,20 +228,9 @@ To test different conditions, you can run your tests multiple times with differe
226228

227229
`[DataSource("System.Data.SqlClient", "Data Source=.\\sqlexpress;Initial Catalog=tempdb;Integrated Security=True", "Data", DataAccessMethod.Sequential), TestMethod]`
228230

229-
### Q: Can I use data-driven tests on my Windows Phone app?
230-
**A:** Yes. Data-driven Coded UI tests for Windows Phone are defined using the DataRow attribute on a test method. In the following example, x and y use the values of 1 and 2 for the first iteration and -1 and -2 for the second iteration of the test.
231-
232-
```csharp
233-
[DataRow(1, 2, DisplayName = "Add positive numbers")]
234-
[DataRow(-1, -2, DisplayName = "Add negative numbers")]
235-
[TestMethod]
236-
public void DataDrivingDemo_MyTestMethod(int x, int y)
237-
```
238-
239-
For more information, see [Use Data-driven coded UI tests on Windows Phone apps](../test/test-windows-phone-8-1-apps-with-coded-ui-tests.md#TestingPhoneAppsCodedUI_DataDriven).
240-
241231
### Q: Why can't I modify the code in the UIMap.Designer file?
242-
**A:** Any code changes you make in the UIMapDesigner.cs file will be overwritten every time you generate code using the UIMap - Coded UI Test Builder. In this sample, and in most cases, the code changes needed to enable a test to use a data source can be made to the test's source code file (that is, CodedUITest1.cs).
232+
233+
**A:** Any code changes you make in the UIMapDesigner.cs file will be overwritten every time you generate code using the UIMap - Coded UI Test Builder. In this sample, and in most cases, the code changes needed to enable a test to use a data source can be made to the test's source code file (that is, CodedUITest1.cs).
243234

244235
If you have to modify a recorded method, you must copy it to UIMap.cs file and rename it. The UIMap.cs file can be used to override methods and properties in the UIMapDesigner.cs file. You must remove the reference to the original method in the Coded UITest.cs file and replace it with the renamed method name.
245236

docs/test/developer-testing-scenarios.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ ms.date: 05/02/2017
44
ms.prod: visual-studio-dev15
55
ms.technology: vs-ide-test
66
ms.topic: conceptual
7-
helpviewer_keywords:
7+
helpviewer_keywords:
88
- "unit testing, create unit tests"
99
ms.author: gewarren
1010
manager: douge
11-
ms.workload:
11+
ms.workload:
1212
- "multiple"
1313
author: gewarren
1414
---
@@ -54,8 +54,7 @@ need.
5454

5555
* [Use UI Automation To Test Your Code](use-ui-automation-to-test-your-code.md)
5656
* [Get started creating, editing and maintaining a coded UI test](walkthrough-creating-editing-and-maintaining-a-coded-ui-test.md)
57-
* [Test UWP apps with Coded UI Tests](test-windows-store-8-1-apps-with-coded-ui-tests.md)
58-
* [Test Windows Phone Apps with Coded UI Tests](test-windows-phone-8-1-apps-with-coded-ui-tests.md)
57+
* [Test UWP apps with Coded UI Tests](test-uwp-app-with-coded-ui-test.md)
5958
* [Test SharePoint Applications with Coded UI Tests](testing-sharepoint-2010-applications-with-coded-ui-tests.md)
6059
* [Introduction to Coded UI Tests with Visual Studio Enterprise (Lab)](http://download.microsoft.com/download/6/2/B/62B60ECE-B9DC-4E8A-A97C-EA261BFB935E/Docs/Introduction%20to%20Coded%20UI%20Tests%20with%20Visual%20Studio%20Enterprise%202015.docx)
6160

docs/test/extending-coded-ui-tests-and-action-recordings-to-support-microsoft-excel.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ author: gewarren
1212
---
1313
# Extend Coded UI Tests and Action Recordings to Support Microsoft Excel
1414

15-
The testing framework for coded UI tests and action recordings does not support every possible user interface. It might not support the specific UI that you want to test. For example, you cannot immediately create a coded UI test or an action recording for a [!INCLUDE[ofprexcel](../test/includes/ofprexcel_md.md)] spreadsheet. However, you can create your own extension to the coded UI test framework that will support your specific UI by taking advantage of the extensibility of the coded UI test framework. The following topic gives an example of how to extend the framework to support the creation of coded UI tests and action recordings for [!INCLUDE[ofprexcel](../test/includes/ofprexcel_md.md)]. For more information about the platforms that are supported, see [Supported Configurations and Platforms for Coded UI Tests and Action Recordings](../test/supported-configurations-and-platforms-for-coded-ui-tests-and-action-recordings.md).
15+
The testing framework for coded UI tests and action recordings does not support every possible user interface. It might not support the specific UI that you want to test. For example, you cannot immediately create a coded UI test or an action recording for a Microsoft Excel spreadsheet. However, you can create your own extension to the coded UI test framework that supports your specific UI by taking advantage of the extensibility of the coded UI test framework.
16+
17+
This article gives an example of how to extend the framework to support the creation of coded UI tests and action recordings for Microsoft Excel. For more information about the platforms that are supported, see [Supported Configurations and Platforms for Coded UI Tests and Action Recordings](../test/supported-configurations-and-platforms-for-coded-ui-tests-and-action-recordings.md).
1618

1719
This section presents a coded UI test extension that can record and play back tests of Excel Worksheets. Each part of the extension is explained in this section and in the code comments for developers who want to create just such an extension.
1820

@@ -40,9 +42,10 @@ Get the sample from this [blog post](https://blogs.msdn.microsoft.com/gautamg/20
4042
The following sections provide information about the sample and its structure.
4143

4244
### Microsoft Excel Add-in: ExcelCodedUIAddinHelper
43-
This project includes an add-in that runs in the Excel process. See [Sample Excel Add-In for Coded UI Testing](../test/sample-excel-add-in-for-coded-ui-testing.md) for a brief overview of the add-in project.
4445

45-
For more information, see [Walkthrough: Creating Your First VSTO Add-in for Excel](http://msdn.microsoft.com/Library/a855e2be-3ecf-4112-a7f5-ec0f7fad3b5f).
46+
This project includes an add-in that runs in the Excel process. See [Sample Excel Add-In for Coded UI Testing](../test/sample-excel-add-in-for-coded-ui-testing.md) for a brief overview of the add-in project.
47+
48+
For more information, see [Walkthrough: Creating Your First VSTO Add-in for Excel](http://msdn.microsoft.com/Library/a855e2be-3ecf-4112-a7f5-ec0f7fad3b5f).
4649

4750
### Excel UI communication: ExcelUIcommunicationHelper
4851
This project includes the `IExcelUICommunication` interface and the information classes that are used to pass data between the Coded UI Testing Framework and Excel. For more information, see [Sample Excel Communicator Interface](../test/sample-excel-communicator-interface.md).
Loading
7.04 KB
Loading
Loading

docs/test/media/automation-id.png

12.7 KB
Loading
44.8 KB
Loading
Loading

docs/test/media/cross-hair-tool.png

52.1 KB
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-11.7 KB
Binary file not shown.
-7.96 KB
Binary file not shown.
Binary file not shown.
-2.5 KB
Binary file not shown.
-16.6 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-8.95 KB
Binary file not shown.
6.01 KB
Loading
Loading
11.3 KB
Loading

docs/test/media/target-icon.png

504 Bytes
Loading
Loading

docs/test/media/toolbox-controls.png

10.8 KB
Loading
3.14 KB
Loading

docs/test/media/uwp-app.png

2.79 KB
Loading

0 commit comments

Comments
 (0)