software test automation using visual studio -...

23
1 Software Test Automation Using Visual Studio - CodedUI

Upload: dinhnhu

Post on 07-Feb-2018

229 views

Category:

Documents


0 download

TRANSCRIPT

1

Software Test Automation

Using Visual Studio - CodedUI

2

Agenda

• What is CodedUI

• Benefits & Limitations

• Supported Platforms

• Quick Walkthrough

• A recommended framework

• Working together with TFS

3

What is CodedUI

• Important key feature in Visual Studio 2010 Premium and

Ultimate versions

• Helps users to create their own automation test scripts for

testing application user interfaces

4

Benefits

• Good support for Microsoft technologies (e.g. Dot net)

• Friendly UI for automation testers to create scripts

• Easily integrated into TFS server and controlled by Test

Manager

5

Limitations

• Too much code may be generated by

CodedUI for describing the UI control

• Sometimes the same code may be

generated more than once by CodedUI.

• Does not support some platforms

–Chrome/Opera/Safari

–Flash/Java

6

Supported Platforms

Platform Release Post

Release

Notes

IE7/IE8 – HTML/AJAX IE9 support (partial) added

with VS\MTM 2010 SP1

Windows Form 2.0+ Built in .NET controls fully

support

WPF 3.5+ Built in .NET controls fully

support

SharePoint 2007&2010

Windows Win32

MFC

FireFox 3.5&3.6 – HTML/AJAX Support Released in

feature pack 2

Silverlight 4.0 Support Released in

feature pack 2

Dynamics(Ax) Partial supported

Citrix/Terminal Service The client need to be on

remote machine

Office Client Apps

IE6 Opportunity for partners

to add this using the

extensibility support Chrome/Opera/Safari

Flash/Java

SAP

Fully Supported

Partial Solution. Further work required in

future to complete

Best efforts with known issues. Users can

work around in these cases in code. No

major ongoing investment

Currently no support but on the roadmap

for future release

Currently no support and none planned

for now

7

CodedUI Walkthrough

Example Test Case:

1. Go to .google. o

2. E ter XBOSoft i to Sear h te t field a d li k Sear h utto

3. Verif the first li k i the sear h result page is XBOSoft

Automation Steps:

1. Create a new project

2. Start recording

3. Insert ascertain point

4. Running scripts

5. Check result

8

CodedUI Walkthrough

Create a new CodedUI project

9

CodedUI Walkthrough

Select using record method: 2 options Record actions from scratch: Choose this method when using CodedUI alone and there are

no existing recorded scripts.

Use existing action recording: This method is usually applied when you have recorded some

steps or actions via test manager. The user can import recorded scripts directly and refine or

edit them.

10

CodedUI Walkthrough

Define a good action method name:

• The name will be applied as a function name in C# code

• Make the name simple and clear

• Using Pascal case: The first letter for each word should be capitalized

11

CodedUI Walkthrough

Add assertion ( Check point )

• Purpose: check the property (Inner Text) of the control (The link) is equal

to the e pe ted alue XBOSoft)

12

CodedUI Walkthrough

Generated script

• The different test steps integrate into a test case

• Each test step may include multiple actions & assertion points

13

CodedUI Walkthrough

Replay the recorded script and check the execution result

Part A: Point out which

control caused the error and the information of the

control.

Part B: Click the link to jump

to the error line of code.

14

The Need for an

Automation Framework • Developing scripts that are maintainable requires a

framework

• Main risks without a good framework include:

Risk Affect

Duplicate scripts Lower quality of the code.

Repeated hard code

Cost a lot of time if there is a need to change the hard

code.

Unmanaged UI controls

One control may be recorded by many times.

Tester has difficulties on finding the correct controls.

No clear boundary among

functions

Testers get confused about their responsibility

therefore some functions may be forgotten

15

Framework

Main advantages with suitable framework:

• Flexibility: easy to scale up & down based on

the project budget and application complexity

• Maintainability: allow testers to maintain and

update the existing scripts easily

• Extendibility: enable efficient integration of

new scripts

16

XBO s Fra e ork Te plate

Key Steps

• Create a test case folder and add test case files based on modules

• Use the UIMap class to store controls and actions

• Create a class for common functions (methods) used in the entire project

• Put hard code (constants) into the project properties setting file

• Create a common setting file used to stored hard coded (constant) values in properties setting file

17

XBO s Fra e ork Features

Scale up and down:

• Data driven tests

• Stores information in XML file

• Multiple UI Maps vs. Single UI Maps

• Running tests on multiple machines via

integration with TFS (Team Foundation

Server)

18

Integration With TFS

What is TFS: • Visual Studio Tea Fou datio Ser er TFS is MSFT s olla oratio platfor • TFS automates the software delivery process

• Provides tools to effectively manage software development projects throughout the IT

lifecycle.

What is Test Manager: • A application in the visual studio to help testers plan their testing effort such as creating test

plan, test suite, test case and test steps.

19

Integration With TFS

Record automation scripts directly in test manager – while executing the test case

manually you can also record the manual steps as a automation scripts.

• Right panel is SUT (System Under Test) where you perform the manual steps.

• Left panel is the action recorder which is used to record the steps.

Action Recorder SUT

20

Integration With TFS

Connect automation scripts with the test cases in TFS

21

Integration With TFS

Test Controller & Test Agent

• Using a Test Controller & Test Agent, the

codedUI automation scripts can be

executed remotely on one or more

machines.

– Test Controller initiates the tests and

collects the results

– Test Agent is the machine running the

automation scripts

22

Integration With TFS

• Execute automation scripts via test agent

• Use Test Manager to control the execution options of the test case and then the

remote test agent will start execute the test cases.

Sending the execution command from Test Manager Execute the automation script on Test Agent

23

Conclusion

• Powerful automation testing tool

• Easy to get started

• Can be integrated into TFS

• A suitable framework is necessary

• Does not support all popular platforms