coded ui - lesson 1 - overview

28
Automatic Testing using the Coded UI Framework Lesson 1 - Overview Omer Karpas

Upload: omer-karpas

Post on 17-Jul-2015

381 views

Category:

Software


2 download

TRANSCRIPT

Automatic Testing using the Coded UI Framework

Lesson 1 - Overview

Omer Karpas

Abbreviations and Professional Terms (Glossary)

Abbreviation or term DefinitionKDT Keywords Driven Testing

AUT Application Under Test

VS Visual Studio

BB Building Block

GUI Graphical User Interface

VB Visual Basic

CUIT Coded UI Test

TC Test Case

Scenario Synonym for Test Case

Keyword Driven Testing In KDT (keyword-driven testing), each keyword corresponds to an individual testing Action or Verification.

Examples: A mouse click

Selection of a menu item

Keystrokes

Opening or closing a window

Verifying a control is visible

Verifying a control is enabled

Etc…

Keyword Driven Testing A keyword-driven test is a sequence of keywords, that simulate user actions on the AUT (Application Under Test).

Basically, to create a test, testers simply order the corresponding keywords of the desired Actions and Verifications.

Keywords are commonly called Modules or BB (Building Blocks).

Keyword Driven Testing Pros:

Reuse of code

Allows non-coding personals to build scenarios from the BB.

Much easier maintenance

Cons: Takes more coding time

Conclusion – KDT is the way to go!

Microsoft Coded UI Framework create automated tests of the user interface (UI). These

tests provide functional testing of the user interface.Automated UI tests enable you to test that the userinterface is functioning correctly.

Microsoft Coded UI Framework Coded UI is a Framework designed to provide

developers a way to:

Interact with the AUT (application under test) Controls, to get their state, values etc..

Interact with the AUT Controls, to Set their state, values etc..

Run their automatic TC (Test Cases).

Microsoft Coded UI Framework Coded UI Framework can handle Controls of the

following types:

WinForms

HTML

WPF (Windows Presentation Foundation)

This is a big advantage of Coded UI because currently the only other tool that handles Custom controls of WPF is QTP.

Microsoft Coded UI Framework Coded UI tests can be written in VB.NET (Visual

Basic) or in C# (C-Sharp).

Coded UI tests can be run separately or as an automated package.

Coded UI tests can be coded manually or by recording Tests using the Coded UI Test Builder.

Microsoft Coded UI Framework Using the KDT approach is up to the developer.

Coded UI framework have very limited special features to support coding with KDT in mind, but it is still highly recommended.

Recording VS Manually Automating

In general, there are two ways to create Automatic tests with the Coded UI framework.

By using the “Coded UI Test Builder”

Recording your actions on the AUT and adding assertions(Verifications) – all without any coding involved.

Currently, the framework is not sufficient in recognizing custom controls, and mapping large scale applications.

Recording VS Manually Automating this way is not compatible with KDT approach, since we will

need to record each scenario from start to end (no reuse of code).

For example, if we need to add another step to some of our CUITs (Coded UI Tests), we will need to record those tests again, from scratch, or we will need to manually code those actions and copy past the code across all tests,

Instead, by using KDT, we would just update one of our Modules.

Recording VS Manually Automating

Writing code using coding capabilities – and this is what we will learn in this course.

What you need (Prerequisites) Visual Studio 2010 Ultimate or Visual Studio 2010

Premium or newer versions of Visual Studio.

SQL express (can be installed as part of the VS2010 installations).

Creating a new Coded UI Project

Open Microsoft Visual Studio 2010 Ultimate (or newer)

Start a new testing project: “File” -> “New Project…” .

In the New Project window, select “Visual C#”-> “Test”, enter a name for the Project and press the OK button to create the test project.

Creating a new Coded UI Project

Creating a new Coded UI Project

Close the “UnitTest.cs” window

Right click on the “UnitTest.cs” in the “Solution Explorer” and select Delete.

Project Entities There are 3 types of entities to our project :

Control Mapping.

Implementation.

Modules.

Control Mapping The control mapping file contains all the AUD

controls.

Most of the controls are mapped in the controls file, but not all, because some can only be detected in run time.

Control Mapping Each class in the file is a single control mapping, or

else, when using it, we will get an exception (error).

The file is like a family graph where each control has its direct childes mapped in its class.

All controls are children’s of the main program window class.

Implementation The implementation file contains a single static class

that contains all the methods (Actions and Verifications) that we want to run on the AUT.

Examples:

Open application.

Click abc button.

Set xyz textbox to “123”.

Modules Each Module file is a “CodedUITest” class.

Each Module contains a call to one method from the Implementation File.

Modules are the Automatic TC building blocks.

Modules Examples:

Open application.

Click abc button.

Set xyz textbox to ValueFromUser.

Test Case (Scenario) The Test Case file contains calls to Modules in a

specific flow to verify the requested functionality.

Example:

Open the application.

Click abc button.

Verify Label text is “123”.

Recommended reading Addison Wesley, “Software Testing with Visual Studio

2010”.

http://blogs.msdn.com/b/mathew_aniyan/archive/2013/02/18/content-index-for-coded-ui-test.aspx

..ספרים וידיאו אתרים ועוד

exercises Create a new Coded UI Project.

Define the following abbreviations: KDT- AUT- VS- BB- GUI- VB- CUIT- TC-

exercises Write the 4 types of areas of the automation project,

and explain each one of them in your own words.