Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Test Automation Coded UI Preview

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Test Automation using

Microsoft Coded UI with C#

Navneesh Garg
Vaibhav Mittal
Microsoft Visual Studio 2015

Learn Automation on a Web


Based Application

Real Life Experiences

Step By Step Instructions

Interview Questions Based on


Microsoft Coded UI

Microsoft Coded UI
Step By Step Guide
All rights reserved. No part of this publication may be reproduced, stored in a retrieval
system or transmitted in any form or by any means, electronic, mechanical, photocopying,
recording, scanning, or otherwise without either the prior written permission of the
author or authorization through payment of the appropriate per-copy fee to the Author.
For permission please contact author at adactin.com/contact.html.

Test Automation Using Microsoft Coded UI with C#

Navneesh Garg
Vaibhav Mittal

ISBN - 978-0-9922935-4-3

Publisher: Adactin Group Pty Ltd.

Copyright 2016 AdactIn Group Pty Ltd.

This document also contains registered trademarks, trademarks and service marks that
are owned by their respective companies or organizations. The publisher and the author
disclaim any responsibility for specifying which marks are owned by which companies
or organizations.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE
AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO
THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND
SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION,
WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY
BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE
ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR
EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT
THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING OR
OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED,
THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT.
NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES
ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS
REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE
OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE
PUBLISHER ENDORSES THE INFORMATION. THE ORGANIZATION OR WEBSITE
MAY PROVIDE OR MAKE OWN RECOMMENDATIONS.l

2
Contents

About the Authors..................................................................................................... 7


Preface....................................................................................................................... 9
1. Introduction to Automation................................................................................ 13
1.1 What is Functional Automation?..............................................................................13
1.2 Why do we Automate?.............................................................................................14
1.3 When should we Automate? Economics of Automation...........................................15
1.4 Commercial and Open Source Automation Tools....................................................16
2. Training Application Walkthrough...................................................................... 18
2.1 TrainingApplication Walkthrough............................................................................18
3. Planning before Automation............................................................................... 24
3.1 Pre-requisites Before you Start Recording..............................................24
3.2 Test Automation Process...........................................................................................28
4. Introduction to Coded UI.................................................................................... 30
4.1 Understand Coded UI Tests..................................................................30
4.2 Coded UI Framework..............................................................................................31
4.3 Supported Configurations and Platforms for Coded UI Tests...................................33
4.4 Installation Requirements for Coded UI...................................................................38
5. C# Basics............................................................................................................. 47
5.1 Object-oriented Programming Concepts..................................................................47
5.2 Language and Syntax Basics.....................................................................................55
5.3 Working with Classes, Objects and Methods............................................................70
5.4 Exception Handling.................................................................................................81

3
Test Automation using Microsoft Coded UI with C#

6. Creating a Coded UI Test.................................................................................... 84


6.1 Coded UI Test Builder.............................................................................................84
6.2 Using the Recorder Controls....................................................................................87
6.3 Editingyour First Script............................................................................................91
6.4 Running the test.......................................................................................................95
7. UI Map............................................................................................................... 97
7.1 How Does Coded UI Replay Scripts?....................................................97
7.2 Simplification of Web Controls in Coded UI test.....................................................98
7.3 Locate the elements on the web page......................................................................100
7.4 What is UI MAP?...................................................................................................102
7.5 UI Map Properties and UI Map editor...................................................................104
7.6 Working with Objects/Controls using UIMap.......................................................108
Multiple Choice Questions Set-1........................................................................... 116
8. Adding Assertions in Coded UI........................................................................ 119
8.1 Need for Assertions................................................................................................119
8.2 Adding an Assertion to a Coded UI script..............................................................120
8.3 Types of Assertionsin Visual Studio.......................................................................129
9. Synchronization in Coded UI........................................................................... 134
9.1 Move recorded script to C# file for hand coding.....................................................135
9.2 Importance of Synchronization..............................................................................136
9.3 Approaches used for Script Synchronization...........................................................137
9.4 Synchronization of Coded UI Script......................................................................139
10. Data Driven Framework................................................................................. 146
10.1 Addinga CSV file to your Coded UI Project.........................................................147
10.2 Writing helper functions in Coded UI Project......................................................151
11. Handling Pop-up Dialogs and Image Capture................................................ 155
11.1 HandlingAlerts or Prompts..................................................................................155
11.2 Capturing Images in Coded UI............................................................................161

4
Contents

12. Working with User Interface Controls............................................................. 165


12.1 Add a web control to Coded UI script...............................................166
Multiple Choice Questions Set-2........................................................................... 174
13. Debugging Scripts.......................................................................................... 177
13.1 Debugging Features..............................................................................................177
13.2 Run Tests in Debug mode with Breakpoints.........................................................179
13.3 Step Commands, Variables and Watch.................................................................182
14. Exception Handling in Coded UI................................................................... 186
14.1 HandlingCoded UI Exceptions............................................................................187
14.2 UITestException Class.........................................................................................195
15. Working with multiple browsers..................................................................... 197
15.1 Installing Microsoft Coded UI components.........................................................197
15.2 Executing Coded UI Tests in Chrome & Firefox..................................................200
16. Test Settings and Playlist Files......................................................................... 202
16.1 Adding a testsettings file.......................................................................................202
16.2 Features of a Test Settings file...............................................................................205
16.3 Using a Playlist.....................................................................................................210
17. Continuous Integration with Team Foundation Server................................... 213
17.1 Team Foundation Server 2015..............................................................................214
17.2 Code Repository..................................................................................................215
17.3 Setting up build definition...................................................................................220
17.4 Microsoft Test Manager (MTM)..........................................................................223
17.5 Advantages and Disadvantages of Continuous Integration....................................226
18. Automation Frameworks................................................................................. 228
18.1 Why do we need Automation Frameworks?..........................................................228
18.2 What exactly is an Automation Framework?.........................................................229
18.3 Types of Frameworks............................................................................................231

5
Test Automation using Microsoft Coded UI with C#

19. Coded UI Functions, Common Questions and Tips....................................... 236


19.1 Initialize and Clean up attributes.......................................................236
19.2 Keyboard and Mouse methods.............................................................................237
19.3 How to record Mouse hovers................................................................................241
19.4 How to Maximize Browser Window.....................................................................242
19.5 Checking an Elements Presence...........................................................................242
19.6 Working with Drop-down Combo Boxes.............................................................243
19.7 Working with Radio Buttons and Groups............................................................244
19.8 Working with Checkboxes....................................................................................245
19.9 Measuring Response time
for Performance Testing using Timer............................................................................245
Multiple Choice Questions Set-3........................................................................... 247
20. Sample Naming and Coding Conventions....................................................... 250
20.1 Sample Naming Conventions...............................................................................250
20.2 Coding Conventions............................................................................................252
21. Common Coded UIInterview Questions........................................................ 256
21.1 Common Test Automation and Coded UI Interview Questions...........................256
22. Sample Test Cases for Automation.................................................................. 260

6
About the Authors

Navneesh Garg
Navneesh Garg is a recognized test automation architect and corporate trainer, specializing
in test automation, performance testing, security testing and test management. As a tool
specialist, he has worked on a variety of functional automation tools including Microsoft
CodedUI, Selenium, HP QTP/UFT, TestComplete, TestPartner, SilkTest, Watir, RFT, and
on varied technologies including Web, Java, .NET, SAP, Peoplesoft and Seibel.
His previous books Test Automation using Unified Functional Testing and Test
Automation using Selenium WebDriver are among best - selling books on test automation.
These books have consistently ranked among the top 100 testing books on Amazon.
He is an entrepreneur and founder of several successful IT companies which encompass
the Adactin Group, CresTech Software, and Planios Technologies.
As an experienced corporate trainer, he has trained professionals in Microsoft CodedUI,
Selenium and other test tools across a wide range of global clients such as Macquarie Bank,
Corporate Express, Max New York Life, Accenture, NSW Road and Maritime Services,
Australian Dept of Education, HCL Technologies, Sapient, Fidelity Group, Adobe Systems,
and many more. He has training experience in diverse geographies such as Australia, India,
Hong Kong and USA.
As a technical test delivery head for his company, he has led and managed functional
automation testing and performance testing teams across a wide range of domains, using
commercial tools and open source tools. Certified in HP QTP, HP Quality Center, HP
LoadRunner, IBM Rational Functional Tester and as a Certified Ethical Hacker, he has
designed several high-end automation frameworks including using Selenium and its
integrations with tools like TestNG, JUnit, Selenium Grid, Jenkins and ANT.

Vaibhav Mittal
Vaibhav Mittal is a seasoned consultant with a vast experience in Information and
Technology. He has experience working on many projects in software development and
testing, exposed to multiple technologies including Microsoft .NET, Java, Oracle, ETL,
Business Intelligence and Analytics. His professional journey enabled him to work across
different geographies like USA, Europe, Japan and India with many esteemed organisations
like Adobe Systems, Oracle, Procter & Gamble, Pfizer and Novartis.

7
Test Automation using Microsoft Coded UI with C#

Vaibhav is Delivery Head with Adactin Group Pty. Ltd, Sydney. During his stint with
Adactin, Vaibhav has worked on various projects in Agile and other project management
methodologies. He is not only an experienced project manager but a tool expert in testing.
His wide knowledge in tools include Microsoft Coded UI, Selenium, UFT, QC/ALM and
many more.
Vaibhav, as a corporate trainer, prepares and delivers courses on various technologies
helping many professionals elevate their IT skills. He has presented papers at international
forums, which makes him a thorough and a passionate IT professional.

8
Preface

Our motivation for writing this book stems from our hands-on experience in the IT and
testing domains and the experience we have gained as automation consultants working in
numerous complex automation projects.
Coded UI, being an automation tool from Microsoft, is gaining huge popularity but still
is not perceived as an easy to use tool especially by testers due to a variety of reasons,
including tool setup, programming background and support issues. A key objective of this
book is to showcase in a simple guided way how to use Microsoft Coded UI so that you can
attain maximum return on investment from using the tool. Not only will you learn how to
use the tool but also how to effectively create maintainable frameworks using Coded UI.

Scope of Topics
As part of the scope of this book we will cover Microsoft Coded UI with C# as the
programming language with Visual Studio 2015.
We will be using Visual Studio 2015 as the main IDE for creating Coded UI tests.
No prior knowledge of C# language is required for this book but having an understanding
of object oriented programming language concepts will definitely help. As part of this book
we will be covering Basics of C# which would be required to use Microsoft Coded UI for
beginner users.
We will also learn how Microsoft Coded UI integrates with continuous Integration tools
like Team Foundation Server.
Ourintent in this book is to discuss the key features of Microsoft Coded UI and cover all
crucial aspects of the tool in order to help you create effective automation frameworks
using Microsoft Coded UI.

Target Audience
The target audience for this book are manual, functional testers who want to learn
Microsoft Coded UI quickly and who want to create effective automation frameworks
that generate positive ROIs to stakeholders.

Salient Features of this Book


This book has been designed with the objective of simplicity and ease of understanding.

9
Test Automation using Microsoft Coded UI with C#

A major fear amongst functional testers who want to learn Coded UI is the fear of the
programming language and coding. We address these fears by covering just enough basics
on C# programming language that will give you the confidence to use Microsoft Coded
UI.
This book follows a unique training based approach instead of a regular text book
approach. Using a step by step approach, weguide you through the exercises using pictorial
snapshots.
We also provide step by step installation and configuration of Visual Studio before using
Coded UI.
Instead of using custom html pages with few form fields and links, this book utilizes a
custom developed, Web based application containing many form fields and links.
Another differentiator is that wehave tried to include many practical examples and issues
which most automation testers encounter in their day-to-day activities. We share our real-
life experience with you to give you an insight into what challenges you could face while
implementing an automation solution on your project. Our practical examples cover how
to use most of the features within Microsoft Coded UI.
We also cover aspects of Continuous Integration tool; Team Foundation Server so that
Coded UI scripts can be integrated with the development environment and run on nightly
builds.
Finally, the book includes a special section devoted to answering the most common
interview questions relating to test automation and Microsoft Coded UI.

Sample Application and Source Used in Book


The sample application used in the book can be accessed at the following URL:
www.adactin.com/HotelApp/

The source code used in the book can be found at the following
link
www.adactin.com/store/

Feedback and Queries


For any feedback or queries you can contact the author at www.adactin.com/contact.html
or email navneesh.garg@adactin.com or vaibhav.mittal@adactin.com

Order this book


For bulk orders, contact us at orders@adactin.com
You can also place your order online at adactin.com/store/

10
Acknowledgements

I would like to thank my family (my parents, my wife Sapna, my wonderful kids Shaurya
and Adaa) for their continued support. Without them this book would not have been
possible.
I would also like to thank my colleagues and clients for the inspiration, knowledge and
learning opportunities provided.
Navneesh Garg
I would like to thank my family (my parents, my wife Sangeeta, my lovely boy Vedaang) who
supported and encouraged me in spite of all the time it took me away from them.Without
them this book would not have been possible.
I would like to express my gratitude to the many people who saw me through this book; to
all those who provided support, talked things over, read, wrote, offered comments, allowed
me to quote their remarks and assisted in the editing, proofreading and design.
Vaibhav Mittal
Special thanks to William B for his review and feedback, which immensely helped as we
worked on this book.

11
12
1.
Introduction to Automation

Introduction
In this chapter we will talk about automation fundamentals and understand what
automation is and the need for automation. An important objective of this chapter is
to understand the economics of automation, and determine when we should carry out
automation in our projects. We will also discuss some popular commercial and open source
automation tools available in the market.

Key objectives:
What is automation?
Why automate? What are the benefits of automation?
Economics of automation
Commercial and Open Source automation tools

1.1 What is Functional Automation?


Automation testing is to automate the execution of manually designed test cases without
any human intervention.
The purpose of automated testing is to execute manual functional tests quickly and in a
cost-effective manner. Frequently, we re-run tests that have been previously executed (also
called regression testing) to validate functional correctness of the application. Think of a
scenario where you need to validate the username and password for an application which
has more than 10,000 users. It can be a tedious and monotonous task for a manual tester
and this is where the real benefits of automation can be harnessed. We might need to
free up a manual functional testers time so that they can perform other key tasks while
automation provides extensive coverage to the overall test effort.
When we use the term automation, there is usually a confusion about whether automation
scope includes functional and performance testing or not Automation covers both.
Functional Automation Used for automation of functional test cases in the
regression test bed.

13
Test Automation using Microsoft Coded UI with C#

Performance Automation Used for automation of non-functional performance test


cases. An example of this is measuring the response time of the application under
considerable (for example 100 users) load.
Functional automation and performance automation are two distinct terms and their
automation internals work using different driving concepts. Hence, there are separate tools
for functional automation and performance automation.
For the scope of this book, we will be only referring to Functional Automation.

1.2 Why do we Automate?


Find below key benefits of Functional Automation:
1. Effective Smoke (or Build Verification) Testing
Whenever a new software build or release is received, a test (generally referred to as smoke
test or shakedown test) is run to verify if the build is testable for a bigger testing effort
and major application functionalities are working correctly. Many times we spend hours
doing this only to discover that a faulty software build resulted in all the testing efforts
going towaste. Testing has to now start all over again after the release of a new build.
If the smoke test is automated, then the smoke test scripts can be run by the developers to
verify the build quality before releasing the code to the testing team.
2. Standalone - Lights Out Testing
Automated testing tools can be programmed to kick off a script at a specific time.
If needed, automated tests can be automatically kicked off overnight, and the testers can
analyze the results of the automated test the next morning. This will save valuable test
execution time for the testers.
3. Increased Repeatability
At times it becomes impossible to reproduce a defect which was found during manual
testing. A likely reason for this could be that the tester forgot which combination of test
steps led to the error message; hence, he is unable to reproduce the defect. Automated
testing scripts take the guess work out of test repeatability.
4. Testers can Focus on Advanced Issues
As tests are automated, automated scripts can be base-lined and re-run for regression
testing. Regression tests generally yield fewer new defects as opposed to testing newly
developed features. So, functional testers can focus on analyzing and testing newer or more
complex areas that have the potential for most of the defects while automated test scripts
can be used for regression test execution.

14
Introduction to Automation

5. Higher Functional Test Coverage


With automated testing a large number of data combinations can be tested which may
not be feasible with manual testing. We use the term Data driven testing which means
validating numerous test data combinations using one automated script.
6. Other Benefits
Reliable: Tests perform precisely the same operations each time they are run, thereby
eliminating human error.
Repeatable:You can test how the software reacts under repeated execution of the
same operations.
Programmable: You can program sophisticated tests that bring out hidden
information from the application.
Comprehensive:You can build a suite of tests that cover every feature in your
application.
Reusable: You can re-use tests on different versions of an application, even if the
user-interface changes.
Better Quality Software:Because you can run more tests in less time with fewer
resources.
Fast:Automated tools run tests significantly faster than human users.

1.3 When should we Automate?


Economics of Automation
Let us take a scenario. If your Test Manager asks you whether it is advisable for your
company to automate an application or not, how would you respond?
In this scenario, the manager is interested in knowing if functional automation will deliver
the organization a better return on investment (ROI) besides improving application quality
and test coverage.
We can determine whether we should automate a given test if we can determine that the
cost of automation would be less than the total cost of manually executing the test cases.
For example, if a test script is to run every week for the next two years, automate the test
if the cost of automation is less than the cost of manually executing the test 104 times (2
years will have 104 weeks).
Calculating the Cost of Test Automation
Cost of Automation = Cost of tool + labor cost of script creation + labor cost of script maintenance
Automate if:

15
Test Automation using Microsoft Coded UI with C#

Cost of automation is lower than the manual execution of those scripts.


The key idea here is to plan for the cost of script maintenance. We have seen a lot of
automation projects fail because project managers did not plan for the labor costs involved
in script maintenance.

Example
Let us give you an example from our personal experience.
We performed some automation work for one of our investment banking clients. We had
a five-member team, which automated almost 3000 test cases in about six months time,
which included around 30 total man months of effort. At the end of project, we gave the
clients testing team, a hand-over of the entire automation suite created by our team. Our
recommendation to them was that they would need at least a one or two member team
to continuously maintain the scripts. This was because there were still functional changes
happening to the application and scripts would need maintenance. But since the client
project manager had no budget allocated for this activity, they over looked this advice
and continued to execute automation scripts. After the first six months of the 3000 test
cases, only 2000 test cases passed, while the rest started failing. These scripts failures were
because script fixes were needed due to application changes. The client team was okay with
that and continued to execute those 2000 working test cases, and got rid of the remaining
1000 test cases, which were now executed manually. After another six months, only scripts
corresponding to 1000 test cases passed. So they got rid of another 1000 test cases and
started executing them manually. After another six months (1.5 years in total), all the
Scripts failed and testing had to move back to manual functional testing.
In the above real-life scenario, the cost of automation and its benefits could have been
reaped, if the client had allocated 1-2 automation testers (could have been part-time) to
maintain the scripts and had properly planned and budgeted for it.

1.4 Commercial and Open Source Automation Tools


This section lists some of the popular Commercial and Open Source Automation Tools.

Vendor Tool Details

OpenSource Selenium Open Source tool and market leader in


(free) Open Source segment. Primarily for Web-
based automation. Supports C#, Java,
Python, and Ruby programming languages.

16
Introduction to Automation

OpenSource Watir Watir stands for Web application testing


(free) in Ruby. It is again primarily for Web
application automation and uses Ruby as the
programming language.

Microsoft VSTP Code UI tests Code UI tests come with Microsoft Visual
studio Enterprise version. You can program
using VB.net or C# as languages of choice.
Fairly good for technical testers.

HP Unified Functional HP UFT (previous version was called QTP)


Testing is the market leader in Test Automation
in the commercial tools segment. It uses
VBScript as the programming language
and its ease of use makes it a tool of choice
against other competing tools.

IBM Rational Functional IBM Rational Functional tester is another


Tester popular test Automation Tool. We can
program in VB.net or Java using this tool. Is
recommended for technical testers.

Microfocus SilkTest Microfocus bought SilkTest from Borland. It


is still a very popular automation tool which
uses 4Test (propriety) language. Good for
technical testers.

SmartBear TestComplete Low cost alternative to other commercial


tools with good automation features.
Supports VBScript, JScript, C++Script,
C#Script and DelphiScript languages.

17
8.
Adding Assertions in Coded UI

Introduction
Till now, we have just executed a set of actions a functional tester will perform. We have not
validated the applications functionality by comparing any actual values on the application
against expected values.
To accomplish this, we will insert assertion points in Coded UI. In this chapter we will
understand the need for assertions and how to insert assertions in Coded UI script. Also
we will understand the different kinds of assertions or checks we can perform in Coded UI.

Example
As a consultant, we need to work with lots of assertion in our everyday work, either manually
or automatically,both depending on the complexity and time. It is extremely important to
design them in advance. Good assertion is necessary; otherwise we risk gathering wrong/
inaccurate information from QA work. This can delay the delivery of software or leave
issues uncovered in the product.To write good assertions, we have to examine the part of
the software to test carefully, find out whats unique about it, and what we need to find out
as a sufficient proof of its working.
In this chapter we will understand the need for assertions and how to add them in a Coded
UI script.

Key objectives:
Need for assertions
Adding assertion to Coded UI script
Type of assertions

8.1 Need for Assertions


An assertion point is a specialized step that compares two values and reports the result. An
assertion point compares the actual results from the test run, with the expected results in
the test case.
A basic test cannot be considered a valid functional test without some form of validation.

119
Test Automation using Microsoft Coded UI with C#

You use a checkpoint to:


Verify the state of an object
Confirm that an application performs as expected
An assertion checks whether an application responds appropriately when a user performs
tasks correctly while testing the application. An assertion can ensure a user is barred
from performing certain tasks by confirming invalid or incomplete data are flagged with
appropriate messages.
Examples of validation are: Specifying limits, conditions, or boundaries
Example
We were once testing an investment banking application where we could create varied
instruments such as bonds, ADRs, etc. When creating an instrument, we would receive a
Save was successful message and a unique instrument number. As part of our test case,
we had to verify that the Save was successful message appears. We also had to verify that
we could search using the same instrument number and verify that all details were saved
correctly. As part of our automation scripts, we had to verify both these functions, so we
used an assertion point to accomplish this.

8.2 Adding an Assertion to a Coded UI script


An assertion can be inserted in the Coded UI script. In this section we will lay out and try
to automate a test scenario containing an expected result.
Test Scenario

Let us take a simple test case for automation from our Hotel Application.
Test Objective: To verify that when a location is selected on the Search Hotel page, the
same location is displayed on the Select Hotel page
Test Steps:
1. Login to the application using valid User credentials
2. Select Sydney from the Location field on the Search Hotel page
3. Keep all the default selections
4. Click the Search Button
5. Verify the correct Location is displayed on the Select Hotel page
Expected Result
1. Sydney should appear in the Location column on the Select Hotel search results
page

120
Adding Assertions in Coded UI

Creating a new project and reusing existing script


To start with a new script, we will follow these steps
1. We will create a copy of our existing project under the same solution. To create a
new project, follow the steps from Chapter 6.
2. Name the project as AddAssertions.

Figure 8.1 Creating a new Coded UI project

Figure 8.2 Provide project name

121
16.
Test Settings and Playlist Files

Introduction
When you run tests from Visual Studio or in thebuild service, the test framework can
collect data such as diagnostic trace information, system information, or a video recording
of a coded UI test. To utilize these capabilities, we use the .testsettings file in our projects.
These diagnostics can be used to simulate potential bottlenecks on the test machines,
reduce the available system memory, or emulate a slow network.
As suggested on MSDN, Test Settings file is used in the following scenarios
Collect diagnostic data to help isolate bugs in your application.
Emulate potential bottlenecks that your app might occasionally encounter in a
production environment.
Run the client, server, and other parts of your app on different machines, to verify
that it behaves as expected in a distributed environment.
Distribute a large number of tests across additional machines.
Run web performance and load tests.
You can create and save a list of coded UI tests that you want to run or view as a group. To
achieve that we create a playlist file.This is used if you want to separate your tests based on
workflows, test suites or product modules.
In this chapter we will learn how to utilize testsettings and playlist files to execute Coded
UI scripts.

Key objectives:
Adding a testsettings file
Features of a Test Settings
Using a Playlist

16.1 Adding a testsettings file


1. To add a testsettings file, right-click on the solution MyFirstScript and go to Add
New Item.

202
17.
Continuous Integration with Team
Foundation Server

Introduction
Why do we need Continuous Integration tools for test automation?
Continuous Integration (CI) tools assist in creating frequent builds (usually on a daily basis)
and running developer driven tests (unit tests) to provide timely feedback on application
quality.
We can integrate our Coded UI based functional test automation scripts with CI tools to
execute our scripts as soon as a new build is created which will provide instant feedback on
application issues.
Popular open source tools include Hudson, Jenkins (the offspring of Hudson),
CruiseControl and CruiseControl.NET.
Popular continuous integration tools include Microsofts Team Foundation Server,
ThoughtWorks Go, Jetbrains Team City, Hudson, Jenkins and Cruise Control.
As part of this chapter we will learn how Coded UI scripts integrate with Team Foundation
Server, one of the popular CI tools provided by Microsoft.

About Team Foundation Server


Team Foundation Server(commonly abbreviated to TFS) is aMicrosoftproduct which
providessource code management(either via Team Foundation Version Control or Git),
reporting, requirements management, project management (for both agile software
developmentandwaterfall teams), automated builds, lab management,and testingand
release management capabilities. It covers the entire application lifecycle. TFS can be
used as a back end to numerous integrated development environments but is tailored
forMicrosoft Visual StudioandEclipse(on Windows and non-Windows platforms).

Key objectives
Team Foundation Server 2015
Code Repository

213
Test Automation using Microsoft Coded UI with C#

Setting up build definition


Microsoft Test Manager

17.1 Team Foundation Server 2015


We will start with downloading Team Foundation Server 2015. To do this, go to the url -
https://www.visualstudio.com/products/tfs-overview-vs.
1. We will then click the Download button in the middle of the web page.

Figure 17.1 Download page of TFS

2. Once installed, open Team Foundation Server Administration Console as shown


below

Figure 17.2 Homepage of TFS Administration Console

214

You might also like