TestComplete 7 Made Easy by Lino Tadros - Falafel Software Inc.
Welcome to TestComplete 7 Made Easy, the new guide to TestComplete 7, the award winning automated testing tool from AutomatedQA Aut omatedQA Corp. We hope you enjoy the book as much as we, at Falafel Software, enjoyed creating it.
TestComplete 7 Made Easy by Lino Tadros - Falafel Software Inc.
Welcome to TestComplete 7 Made Easy, the new guide to TestComplete 7, the award winning automated testing tool from AutomatedQA Aut omatedQA Corp. We hope you enjoy the book as much as we, at Falafel Software, enjoyed creating it.
TestComplete TestComplete 7 Made M ade Easy Copyright © 2009 AutomatedQA Corp. - 2.0 Release All rights rese rved. rved. No parts of this work m ay be reproduced in any form form o r by any mean s - graphic, electronic, or mechan ical, including photocopying, recording, recording, taping, or information storage and retrieval systems - without the the written permission of the publisher. Products that are referred referred to in this docum ent may be either tradema tradema rks and /or registered trademarks of the the respe ctive ctive owners . The The publis her and the author make no claim to thes thes e tradem tradem arks. While every every precaution has b een taken in the preparation of this docum ent, the publis her and the author ass ume no respo nsi bility for errors errors or om iss ions , or for damages resulting from the use of information contained in this this docume nt or from from the us e of programs and s ource code that may accompany it. In no event event shall the publis her and the author be liable for any loss of profit profit or any other comme rcial damag e caus ed or alleged to have been caused directly or indirectly by this document. Printed: August 2009
Publisher AutomatedQA Corp. Corp. Authors Alain "Lino" Tadros Steve Trefethen
Special thanks to: All the team members at AutomatedQA worldwide for creating a magnificant piece of software in TestComplete 7. The authors also would lik e to thank the Falafel team memb ers in Colorado, Colorado, Texas and California for their feedback, guidance and recommendations on the subjects of the manual. Falafel would like to thank Mr. Derek Langone and Mr. Drew Wells for their trust and belief in the quality of Falafel Software's work.
Technical Editors Noel Rice Drew Wells Cover Designer Matt Kurvin Team Coordinator Lino Tadros Production Falafel Software Inc.
Falafel would also like to thank Bobby Edgar, Adam Seeley, Andrew West ergren, ergren, As hley Steenbruggen, Steenbruggen, Gerry McMan McManus, us, Jim McDonough, Miles Kane, Nick Lord and of course the greatest Nick Olivo for their continuous support and friendship to the entire Falafel team. Last but not least, thank you to all our families for their support and patience while we wrote the book
4
TestComplete 7 Made Easy
Table of Contents Fore w ord
10
12
Part I Introduction Introduction 1
Introduction ................................................................................................................................... to TestComplete 12
2
Who Should ................................................................................................................................... Read this Book 13
3
How the ................................................................................................................................... Book is Organize Organize d 13
17
Part II Keyword Testing 1
Objectives ................................................................................................................................... 17
2
Recording ................................................................................................................................... Your First Test Test 17
3
Editing ................................................................................................................................... a Keyword Test 20
4
Data Driven ................................................................................................................................... Keyword Testing 24
5
Summary ................................................................................................................................... 34
Part III III Overview of T esting esting and T estComplet estComplete e
36
1
Objectives ................................................................................................................................... 36
2
Terminology ................................................................................................................................... 36
3
Types................................................................................................................................... of Testing 36
4
Before ................................................................................................................................... You Begin 37
5
Your Most Mos ................................................................................................................................... t Important Im portant Te st 39
6
Summary ................................................................................................................................... 40
Part IV IV T estComplet estComplete e IDE IDE
42
1
Objectives ................................................................................................................................... 42
2
Menus ................................................................................................................................... and Toolbars 42
3
Pane ls ................................................................................................................................... and Workspaces Workspaces 44 Project Explorer ............................ .......................................... ............................. ............................. ............................ ............................. ............................. ............................ ............................. .......................... ........... 44 Object Browser ............................ .......................................... ............................. ............................. ............................ ............................. ............................. ............................ ............................. .......................... ........... 47 Process Tree ............................ .............. Pane ............................. ............................. ............................ ............................. ............................. ............................ ............................ ............................. ......................... .......... 48 Object Properties ............................ .............. Pane ............................. ............................. ............................ ............................. ............................. ............................ ............................ ............................. ......................... .......... 50 Object Recognition ............................ ........................................... ............................. ............................ ............................. ............................. ............................ ............................ ............................. ......................... .......... 56 Introduction
............................ .......................................... ............................ ............................. ............................. ............................ ............................. ............................. ....................... ......... 56
White-Box Applications ............................ .......................................... ............................ ............................. ............................. ............................ ............................. ............................. ....................... ......... 57 Editor
............................ .......................................... ............................. ............................. ............................ ............................. ............................. ............................ ............................. .......................... ........... 59
Code Completion ............................ ........................................... ............................. ............................ ............................. ............................. ............................ ............................ ............................. ......................... .......... 59 Bookmarks............................ ........................................... ............................. ............................ ............................. ............................. ............................ ............................ ............................. ......................... .......... 60 Editor Options ............................ ........................................... ............................. ............................ ............................. ............................. ............................ ............................ ............................. ......................... .......... 61 Debugging............................ ........................................... ............................. ............................ ............................. ............................. ............................ ............................ ............................. ......................... .......... 63 Breakpoints
............................ .......................................... ............................ ............................. ............................. ............................ ............................. ............................. ....................... ......... 63
Call Stack
............................ .......................................... ............................ ............................. ............................. ............................ ............................. ............................. ....................... ......... 64
Locals
............................ .......................................... ............................ ............................. ............................. ............................ ............................. ............................. ....................... ......... 65
Watch List
............................ .......................................... ............................ ............................. ............................. ............................ ............................. ............................. ....................... ......... 66 Copyright Copyright © 2009 AutomatedQA AutomatedQA Corp. - 2.0 Release
Contents
Visualizer
5
............................ .......................................... ............................. ............................. ............................ ............................. ............................. ............................ ............................. .......................... ........... 70
Objectives ............................ ........................................... ............................. ............................ ............................. ............................. ............................ ............................ ............................. ......................... .......... 70 Enabling the ............................ .............. Visualizer ............................. ............................. ............................ ............................. ............................. ............................ ............................ ............................. ......................... .......... 70 Working w............................ .............. ith Visualizer ............................. Images Images ............................. ............................ ............................. ............................. ............................ ............................ ............................. ......................... .......... 71
4
Summary ................................................................................................................................... 73
Part V Projects Projects and Suites Suites
75
1
Objectives ................................................................................................................................... 75
2
Project ................................................................................................................................... Anatomy 75
3
New Project ................................................................................................................................... Wizard 79
4
Hands ................................................................................................................................... on Lab: Create a Simple Test 81
5
Summary ................................................................................................................................... 82
Part VI Project Items
84
1
Objectives ................................................................................................................................... 84
2
Project ................................................................................................................................... Items 84 Tes ted Applications Applicati ............................ .............. ons ............................ ............................. ............................. ............................ ............................. ............................. ............................ ............................. .......................... ........... 85
3
Summary ................................................................................................................................... 87
Part VII Test Log
89
1
Objective ................................................................................................................................... 89
2
Test Log ................................................................................................................................... 89
3
Emailing ................................................................................................................................... Result 90
4
LockEvents ................................................................................................................................... 91
5
Summary ................................................................................................................................... 92
Part VIII VIII Name Mapping
94
1
Objectives ................................................................................................................................... 94
2
Map to ................................................................................................................................... Object 94
3
Highlight ................................................................................................................................... Objects 99
4
Mapping ................................................................................................................................... Dialog 101
5
Aliases ................................................................................................................................... in Scripts 102
6
Summary ................................................................................................................................... 102
Part IX Unit Testing
104
1
Objectives ................................................................................................................................... 104
2
Supported ................................................................................................................................... Unit Testing Types 104
3
NUnit ................................................................................................................................... Example 105
4
Hands ................................................................................................................................... on Lab: Running a Unit Test 108
5
Summary ................................................................................................................................... 110
Part X Manual Testing 1
112
Objectives ................................................................................................................................... 112
Copyright Copyright © 2009 AutomatedQA AutomatedQA Corp. - 2.0 Release
5
6
TestComplete 7 Made Easy
2
Setting ................................................................................................................................... up a Manual Test Project 112
3
Hands ................................................................................................................................... on Lab: Create a Manual Test 113
4
Hands ................................................................................................................................... on Lab: Scripting and Manual Testing 120
5
Summary ................................................................................................................................... 124
Part XI Basic Record and Playback
126
1
Objectives ................................................................................................................................... 126
2
Overview ................................................................................................................................... 126
3
Recording ................................................................................................................................... Toolbar Anatomy 127 Adding Text ............................ .......................................... ............................ ............................. ............................. ............................ ............................. ............................. ............................ .......................... ............ 128 Changing Recording ............................ .......................................... Types ............................ ............................. ............................. ............................ ............................. ............................. ............................ .......................... ............ 129 Pausing
............................ .......................................... ............................ ............................. ............................. ............................ ............................. ............................. ............................ .......................... ............ 130
Stopping
............................ .......................................... ............................ ............................. ............................. ............................ ............................. ............................. ............................ .......................... ............ 130
4
Hands ................................................................................................................................... on Lab: Perform a Basic Recording 130
5
Summary ................................................................................................................................... 131
Part XII Low Level Procedure
133
1
Objectives ................................................................................................................................... 133
2
Recording ................................................................................................................................... 133
3
Hands ................................................................................................................................... on Lab: MS Paint Test 136
4
Summary ................................................................................................................................... 140
Part XIII XIII Stores and Checkpoints Checkpoints
142
1
Objectives ................................................................................................................................... 142
2
Region ................................................................................................................................... Checkpoints 142
3
File ................................................................................................................................... Comparisons Comparisons 150
4
Object ................................................................................................................................... Comparisons 154
5
Hands ................................................................................................................................... on Lab: Comparing File, Picture and a Property 156
6
Summary ................................................................................................................................... 163
Part XIV XIV Data-Driven Data-Driven T esting esting
165
1
Objectives ................................................................................................................................... 165
2
Overview ................................................................................................................................... 165
3
Modifying ................................................................................................................................... Scripts 165
4
Hands ................................................................................................................................... on Lab: Modifying Recording for Data-Driven Testing 167
5
Summary ................................................................................................................................... 171
Part XV Event Handling andling
173
1
Objectives ................................................................................................................................... 173
2
General ................................................................................................................................... Events Definition 173 OnLogError ............................ .......................................... ............................ ............................. ............................. ............................ ............................. ............................. ............................ .......................... ............ 175
3
Unexpected ................................................................................................................................... Windows 176
Copyright Copyright © 2009 AutomatedQA AutomatedQA Corp. - 2.0 Release
Contents
7
4
Hands ................................................................................................................................... on Lab: Create Unexpected Window Handler 177
5
Summary ................................................................................................................................... 181
Part XVI Working with Databases
183
1
Objectives ................................................................................................................................... 183
2
ADO................................................................................................................................... 183
3
Hands ................................................................................................................................... on Lab: Query Database 186
4
Summary ................................................................................................................................... 194
Part XVII Web Page Testing
196
1
Objectives ................................................................................................................................... 196
2
Web................................................................................................................................... Page Model 196
3
Naming ................................................................................................................................... Conventions 197
4
We b................................................................................................................................... Comparison Checkpoint 197
5
Web................................................................................................................................... Accessibility Checkpoint 200
6
Finding ................................................................................................................................... We b Page Elements 203
7
Dynamic ................................................................................................................................... HTML 205
8
Hands ................................................................................................................................... on Lab: Work with Web Pages 208
9
Summary ................................................................................................................................... 212
Part XVIII WebServices Testing
214
1
Objectives ................................................................................................................................... 214
2
Testing ................................................................................................................................... against WSDL 214
3
We bServices ................................................................................................................................... Checkpoint 219
4
We bServices ................................................................................................................................... Testing Dialogs 224
5
XML................................................................................................................................... Checkpoint 226
6
Hands ................................................................................................................................... on Lab: Testing a SOAP 1.2 Web Service 228
7
Summary ................................................................................................................................... 235
Part XIX HTTP Performance Testing
237
1
Objectives ................................................................................................................................... 237
2
Performance ................................................................................................................................... Testing Your We b Applications 237
3
HTTP ................................................................................................................................... Load Testing Options 237
4
Cookie ................................................................................................................................... Handling 239
5
Recording ................................................................................................................................... 239
6
Connections, ................................................................................................................................... Reque sts and Responses 241
7
Visual ................................................................................................................................... Creation of a Loa d Test 242
8
Analysis ................................................................................................................................... of the Test Log 244
9
Modifying ................................................................................................................................... HTTP Traffic 246
10
Hands ................................................................................................................................... on Lab: Working with HTTP Traffic 248
11
Summary ................................................................................................................................... 251
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
7
8
TestComplete 7 Made Easy
Part XX Remote Agent
253
1
Objectives ................................................................................................................................... 253
2
Installing ................................................................................................................................... Remote Agent 253
3
Running ................................................................................................................................... Remote Agent 253
4
Configuring ................................................................................................................................... Remote Agent 255
5
Hands on Lab: Working with Remote Agent for HTTP Load Testing ................................................................................................................................... 257
6
Summary ................................................................................................................................... 261
Part XXI Distributed Testing
263
1
Objectives ................................................................................................................................... 263
2
Network ................................................................................................................................... Suites 263
3
Hosts ................................................................................................................................... 265
4
Jobs/Tasks ................................................................................................................................... 266
5
SynchPoints ................................................................................................................................... 267
6
Setup ................................................................................................................................... 268
7
Summary ................................................................................................................................... 274
Part XXII User Forms
276
1
Objectives ................................................................................................................................... 276
2
Creating ................................................................................................................................... 276
3
Scripting ................................................................................................................................... 278
4
Summary ................................................................................................................................... 278
Part XXIII Best Practices
280
1
General ................................................................................................................................... 280
2
Web................................................................................................................................... Page 282
Part XXIV Cheat Sheet
284
1
Keyboard ................................................................................................................................... Shortcuts 284
2
Code ................................................................................................................................... Completion 286
3
Keyboard ................................................................................................................................... Handling in Recorder 287
4
Global ................................................................................................................................... Shortcuts/Changing Keyboard Emulation 288
Part XXV AutomatedQA
292
1
History ................................................................................................................................... 292
2
Product ................................................................................................................................... Offerings 292
Part XXVI Professional Offering
298
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Contents
Index
9
300
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
9
10
Foreword
Foreword TestComplete is more than just a test automation tool – it does that, of course, but it also integrates all the other aspects of testing – from organizing your manual tests, to doing unit testing and functional testing, and all the way to performance and load testing. That’s already a daunting amount of functionality, and then on top of that TestComplete supports multiple programming languages and platforms and it comes out of the box bundled with support for a long list of third party components. I almost forgot – you can also write your scripts in any of several standard scripting languages, too. That’s a lot of ground to cover. It’s easy to get started with TestComplete, but to take full advantage of everything that it has to offer you need not only to understand the built-in functionality, but you also need a deep knowledge of your testing trade and software development best practices. Anyone writing a book on TestComplete had better have that kind of depth and experience. To be honest, there just aren’t that many experts in this field that have such experience and are also proficient and entertaining technical writers. When I first heard a new book on TestComplete was going to be written I crossed my fingers that the superstar team at Falafel Software would be involved in some way. I just can’t think of anyone more appropriate for the task. Now that I’ve reviewed the first manuscript, I can see that I was right… (again). This book is terrific. It will definitely end up on the nightstands of all discerning TestComplete users. I strongly recommend it to everyone from novices just getting their feet wet, to expert testers ready to go to the next level. Finally, my deepest respects go to Lino Tadros, founder and CEO of Falafel software, for his expertise and his appreciation that all work and no fun is no way to go in life, and especially in testing. Thank you, Lino, for such a fine book and even more, thank you for being my friend and knowing all there is to know about Ouzo.
Atanas Stoyanov Original Founder of AutomatedQA
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Part
I Introduction
12
TestComplete 7 Made Easy
1
Introduction
1.1
Introduction to TestComplete About TestComplete Today automated testing plays a vital role in many software development projects. Automated testing has long been thought critical for large software development organizations, but is often considered to be too expensive and difficult to implement for smaller companies. AutomatedQA’s TestComplete breaks this stereotype. It delivers automated functional, unit, regression, manual, data-driven, object-driven, distributed and HTTP load, stress and scalability testing in one easy-to-use and totally integrated package at an affordable price. TestComplete is a full-featured environment for automated testing of Windows, .NET, Java, WPF (XAML) applications, web pages, web servers and web services. It has been designed to free developers and QA departments from the massive drain on time and energy required by manual testing. TestComplete offers systematic, automated, and structured testing, with superior support for .NET, Java, Visual C++, Visual Basic, WPF (XAML), Delphi, C++Builder and web applications. It is equally oriented for testing 32-bit and 64-bit applications. With TestComplete you can also test PowerBuilder, FoxPro, Access and other applications. TestComplete is the ultimate solution to perform nightly tests and to help you get reliable daily builds of your software. TestComplete tools and features let every member of your team, developers and nondevelopers, no matter how technically savvy, contribute to your testing projects. Once you start using TestComplete, you will be able to turn every test run into a key contribution to your overall development efforts. TestComplete will keep your projects on schedule and on spec, the team confident, and the work 100% productive. With TestComplete you and your team can implement comprehensive software testing strategies, “automating the non-automatable” for maximum return on investment: “In my opinion, [TestComplete] is a must-have tool for any software developer who believes in applying a rigorous testing methodology to his products. The abili ty to work with Visual C++, Visual Basic, C++Builder, Delphi, Java and .NET applications means that you’re virtually getting several tools in one, and the wide variety of scripting languages means you can work in whatever language you’re most comfortable with. Even if you have no interest in automated testing procedures, [TestComplete’s] fascinating ability to ‘automate the non-automatable’ is sure to find a use on your desktop!” Dave Jewell, Delphi Magazine
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Introduction
1.2
13
Who Should Read this Book You should read this book if: ·
·
·
1.3
You have never used TestComplete and want to learn what it's all about. You have worked in a QA environment and want to learn the AutomatedQA approach using TestComplete. You have used TestComplete and want to make your knowledge more comprehensive.
How the Book is Organized AutomatedQA This section includes a brief history of how AutomatedQA came into being and its mission. The section also includes a 1000 foot view of its award winning products TestComplete, Automated Build Studio, AQtime, AQdevTeam, TestExecute and TestRecorder.
Overview of Testing and TestComplete This section discus ses an approach to organizing your efforts for maximum return on your automatedtesting investment. In this section you'll learn basic testing terminology, types of testing, strategies for organizing and communicating your testing results, how to build a "smoke test" and best practices for building durable tests that remain effective over time.
TestComplete IDE This section introduces the basic tools you need to work effectively with TestComplete, including an exploration of the TestComplete environment and debugging basics.
Projects and Suites This chapter covers the structure of a TestComplete project and the parts that make up the various testing functionality included in a project. This chapter discusses the difference between a Project and Project Suite, the components of a Project, how to use the Project Wizard and how to create a simple test.
Project Items This section provides an overview of all project item types with additional detail on the Tested Application.
Test Log This section discusses the test log and the types of messages available in TestComplete. We will learn how to email the test log and also how to reduce the size of the test log.
Name Mapping This section introduces Named Mappings and Aliases used to handle long object identifiers and to provide identifiers with meaningful names.
Unit Testing
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
14
TestComplete 7 Made Easy
This section discusses unit testing, the types of unit test frameworks supported by TestComplete and provides an example of using an NUnit unit test.
Manual Testing This section looks at the structure of a TestComplete project and the parts that make up the various testing functionality included in a project.
Basic Record and Playback This section demonstrates how to perform basic record and playback tasks.
Low Level Procedure This section discusses TestComplete's Manual Testing features, how to construct a simple manual test using one of the provided sample applications and how to interact with manual tests from scripts.
Stores and Checkpoints This section explores how to c ompare various testing input including visual areas of the s creen, files and objects.
Data-Driven Testing This section covers how the Data Driven Testing plug-in consumes common data ty pes.
Event Handling This section explains how to respond to events that occur during testing and explains how to handle unexpected windows.
Working with Databases TestComplete includes general-purpose mechanisms for connecting to ext ernal databases. This section explains the connectivity options, how to connect and run queries during a test.
Web Page Testing This section discusses how TestComplete represents web pages in the Object Browser, how to navigate between web pages and how web checkpoints are used. This section also talks about strategies for locating and testing dynamic HTML elements.
WebServices Testing This section demonstrates how to test a web service, including how to import web service meta data, calling simples methods, creating web service types and calling complex methods. This section also explains how to create a web service checkpoint.
HTTP Performance Testing This section explores HTTP performance test ing and other types of performance test ing (e.g. load, stress , scalability). You will als o learn about HTTP traffic recording and modification.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Introduction
15
Remote Agent Remote Agent is a tool that allows for the distribution of HTTP loads tests across a network of computers. This section explains how to install, configure and run Remote Agent.
Distributed Testing This section explains how tests are run on several computers at the same time.
User Forms This section demonstrates how to create user forms and manipulate them using scripts.
Best Practices This section contains notes on best practices for testing in general and web pages in specific.
Cheat Sheet Here you'll find a handy reference to TestComplete general keyboard shortcuts, shortcuts for Code Completion, k eyboard handling in the recorder, how to change global shortcuts and how to change keyboard emulation.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Part
II Keyword Testing
Keyword Testing
2
Keyword Testing
2.1
Objectives
17
In this section we'll take a look at the Keyword Testing features of TestComplete and you will learn how to: ·
Record Keyword tests
·
Add a checkpoint to a test
·
Convert a recorded test to a Data Driven Test
The goal of Keyword Testing is to get developing testcases rapidly and in this chapter we'll do exactly that by developing a frequently requested testcase scenario using Data Driven testing.
2.2
Recording Your First Test For our first Keyword Test we'll start from scratch and record a simple data entry scenario using the Orders sample application. To get started: ·
Launch TestComplete
·
Click Record a New Test on the Start Page
Record a New Test Te st from the Tes tComplete Start Page
You will be prompted to c reate a new project. ·
In the Project Name field type: Keyword
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
18
TestComplete 7 Made Easy
·
Click Create
Create a new Project
As soon as you click Create the TestComplete main window is hidden and you'll see the recording toolbar:
Recording a Keyword Test You are now recording a test! At this point, we'll launch the Orders sample application, perform the data entry below, end the recording and review the results. NOTE: This test was recorded using Windows Vista and may vary slightly if you're using an older version
of Windows 1. Press the Windows key to display the Start menu 2. Type: C:\Users\Public\Documents\TestComplete 7 Samples\Open Apps\OrdersDemo\C#\bin\Debug\Order.exe and press the Enter key NOTE: If you're on Windows XP select "Run" and use the Run dialog to start the application with this path: C:\Documents and Settings\All Users\Documents\TestComplete 7 Samples\Open Apps\OrdersDemo\C#\bin\Debug\Orders.exe 3. You should now see the Orders sample application on screen Next we're going to perform the following data entry for our test:
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Keyword Testing
19
1. Select Order | New Order to view the Order dialog 2. Increment the Quantity to 2 by clicking on the up arrow of the UpDown control 3. Type: "Jon Doe" in the Customer Name field, "123 Easy" in the street field, "CA" in the State field and "95060" in the Zip field 4. Finally click the OK button to save the order
Order dialog
Now, c lick the St op button on Recording toolbar (the blue square icon) and the TestComplete main window will reappear with the Keyword Test Editor open. Congratulations, you've now recorded your first Keyword test! TestComplete should now look like this:
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
20
TestComplete 7 Made Easy
Recorded Keyword Te st
2.3
Editing a Keyword Test Now that we've recorded our first Keyword test let's take a closer look at the Keyword Test Editor . The editor consists of three pages (see the tabs at the bottom of the editor): ·
Test Steps (what you are currently looking at)
·
Variables - used to specify values that are local to this test which can be passed from one operation to
the next ·
Parameters - used to specify parameters to the test
The main parts of the Test Steps page are (moving clockwise from the top left): ·
Operations palette - lis t all of the available operations y ou can perform in a Keyword test
·
Keyword Test Editor toolbar
·
Test Steps tree - displays all of the steps of the test
·
Tabs to access the above editor pages
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Keyword Testing
21
Notice as you read through the Test Steps we recorded it's easy to make sense of the various operations. The Keyword Testing feature is very powerful and automatically leverages other features of TestComplete such as NameMapping, Aliases and TestedApps whereas in previous versions you had to configure each of these features manually prior to recording .
Keyword Editor Toolbar From the Keyword Editor Toolbar you can:
·
Record a new test
·
Append operations to an existing test
·
Run a Keyword test
·
Add Variables and Parameters to the test
·
Manipulate Test Steps (move up/down, indent/outdent steps)
·
Edit a test description
Editing Keyword Test Steps
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
22
TestComplete 7 Made Easy
The Test Steps tree allows you to manipulate the test by adding, deleting and editing steps. The Test Steps tree supports many standard editing operations such as Undo, Redo, Select All, Cut, Copy and Paste available from the right click menu or main menu. As is typical with recorded tests you'll want to review the results of the recording and tidy up the test by removing any unnecessary or redundant steps. Next, we do just that and illustrate how easy it is to edit Keyword tests. Deleting Unnecessary Steps
In our recorded test you'll notice TestComplete created a s tep reading "Run TestedApp Orders" and as you can see from the Project Explorer we now have an Orders subnode listed under TestedApps that it launches. As a result, we can delete the steps recorded to manually launch the Orders application in favor of using the Run TestedApp step. To do that simply: 1. Click the first step of the test starting with Explorer 2. Holding the Shift key down press the down arrow to highlight all of the steps up to, but not including the Run Tested Apps step 3. Press the Delete key to delete them from the test
Delete commands use d to start Orders.exe
At this point, you've completed your first test now, click the Run Test button on the toolbar and watch the results! Adding a Checkpoint Operation to a Test
Next, we'll add a Checkpoint operation to our test verifying the Total field on the Order dialog reflects the correct value (Quantity x Price). To verify this data we're going to use a Checkpoint operation and add it to our test after we've performed the data entry on the quantity field. To add a checkpoint perform the following actions: 1. Click the Search box at the top of the Operations palette 2. Type: property 3. Drag the item Property Checkpoint onto the Steps tree and drop it on the step where we set the Quantity to display the Create Property Checkpoint dialog
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Keyword Testing
23
4. Click on the Orders application and select Order | New Order to display the Order dialog 5. Use the Finder Tool on the Create Property Checkpoint dialog to select the Total edit box on the Orders dialog
6. On the Create Property Checkpoint dialog click Next 7. Type: "wText" (without quotes) into the Search edit box at the top right hand of the dialog and click Next 8. Change the Value to "200" (without quotes) and click Finish Your Keyword Test should now contain a step that looks like the If ... Then step below:
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
24
TestComplete 7 Made Easy
Keywor d Test with If ... Then operation inserted
2.4
Data Driven Keyword Testing Building upon our existing Keyword test we can extend it to support Data Driven Testing and remove the instances where we have hard coded data entry. Here is what we need to do: ·
Create a CSV file with our test data
·
Add the CSV file to the Files Store
·
Modify the test to make it data driven
Creating a CSV File
Using Windows Notepad we can create a simple CSV text file that contains our test data, notice that the first line of the file specifies the column names.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Keywor eyword d Test Testing ing
25
CSV file for data driven testing
To create this text file: 1. Start Windows Notepad 2. Enter the data pictured above 3. Save the file to disk as "names.csv" Adding the the CSV Fil e to the Fi les Store Store
Next, we need to add this file to our Files Store. 1. From the TestComplete Project Explorer expand the Stores node, right click the Files subnode and select New Item
Copyright Copyright © 2009 AutomatedQA AutomatedQA Corp. - 2.0 Release
26
TestComplete 7 Made Easy
Add names.csv to the Files Store
2. On the Add File dialog locate names.csv and add it to the Files Store Modifying our Keyword Test to Perform Data Driven Testing
Now that we have data to work with we can modify our test making it data driven. Here are the tasks we need to perform: ·
Initialize the CSVDriver
·
Create a loop that will iterate over all of the data
·
Indent our test steps to use the loop
·
Modify our data entry steps to use the data from the CSVDriver
·
Add a step to move to the next record
Let's walk through each of these tasks: 1. Under Test Actions we'll add the Call Object Method operation operation by dragging dragging it onto the Orders step: st ep:
Copyright Copyright © 2009 AutomatedQA AutomatedQA Corp. - 2.0 Release
Keywor eyword d Test Testing ing
27
Adding the Call Object Method operation to our test
2. On the Call Object Method dialog enter "DDT" (without the quotes) as the object and click Next >
Copyright Copyright © 2009 AutomatedQA AutomatedQA Corp. - 2.0 Release
28
TestComplete 7 Made Easy
3. Select CSVDriver as the method and click Next >
4. Click the ellipsis (...) next t o the Filename parameter, parameter, select selec t Code Expression Expression from the Mode dropdown and enter a Value of Files.FileNameByName('names.csv') then click OK
Copyright Copyright © 2009 AutomatedQA AutomatedQA Corp. - 2.0 Release
Keywor eyword d Test Testing ing
29
5. Click the Finish button to complete the Call Object Method step Next, we'll add some logic to iterate over our data. 1. On the Operations palette under Statements select While Loop and drop it onto the Orders step.
2. The The While Loop dialog will appear and click the ellipsis (...) under the Value1 column then select Code Copyright Copyright © 2009 AutomatedQA AutomatedQA Corp. - 2.0 Release
30
TestComplete 7 Made Easy
Expression from the Mode dropdown and enter a Value of: DDT.CurrentDriver.EOF() then click OK
3. Click on the edit box on under the Value2 column type false then click OK
Now, we need to nest our existing test steps under the While Loop Loop step by indenting the remaining steps.
Copyright Copyright © 2009 AutomatedQA AutomatedQA Corp. - 2.0 Release
Keyword Testing
31
1. Click the Orders step 2. Holding the Shift key down use the down arrow to multi-select the remaining test steps 3. Click the Indent button on the Keyword Editor Toolbar
Next, we need to change our data entry steps to use values from the CSVDriver. We'll walk through changing the Customer data entry field and you can repeat the steps for the Street and Zip fields. 1. Double click where it says "Jon Doe" to display the On-Screen Action dialog 2. Click the ellipsis (...) under the Value column to display the Edit Parameter dialog 3. On the Mode dropdown select Code Expression and change the Value to read DDT.CurrentDriver. Value('name') then click OK then Finish
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
32
TestComplete 7 Made Easy
4. Repeat the same steps for the Street and Zip edit fields only changing the parameter passed to DDT. CurrentDriver.Value(...) to reflect the correct field.
At this point, we're almost done, the only thing remaining is to add a step that will move the CSV record pointer to the next row of data. 1. On the Operations palette select Test Actions then drag and drop the Run Code Snippe t operation to the very bottom of our Keyword Test
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Keyword Testing
33
2. For the code snippet use DDT.CurrentDriver.Next() then click OK 3. Finally, click the Indent button on the toolbar to indent our Run Code Snippe t step and we're done! Your test s hould look like this:
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
34
2.5
TestComplete 7 Made Easy
Summary In this chapter we covered Keyword Testing including recording and editing Keyword Tests. You should be familiar with how to record Keyword tests and edit them using the Keyword Test Editor.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Part
III Overview of Testing and TestComplete
36
TestComplete 7 Made Easy
3
Overview of Testing and TestComplete
3.1
Objectives In this section we'll discuss an approach to organizing your efforts to maximize the return on your automated testing investment. The content in this section is based on years of experience "in the trenches" from people who have worked to build a productive and efficient automated test environment. In this section you'll learn about:
3.2
·
Basic testing terminology
·
Types of testing
·
Strategies for organizing and communicating your testing results
·
How to build a "smoke test"
·
Best practices for building durable tests that remain effective over time.
Terminology First, let's define a few terms to help facilitate a discussion on testing:
3.3
·
QA - the Quality Assurance team
·
R&D - the Research and Development team developing the application being tested
·
Build - a specific revision of the application under test that is submitted to QA
·
Application - the code that will be tested using TestComplete
Types of Testing Manual Testing Manual Testing is where a tester methodically exercises the features of a product or product area without the aid of test automation. The single greatest strength of manual testing is that it is truly real-world testing, meaning that the tester can utilize the application under test the same way an end user would. Through manual testing t he tester can provide a wide variety of feedback about the application under test not limited to simply reproducing bugs. The major weakness of manual testing is that it is time consuming, tedious and requires extended periods of very focused attention which can be very difficult to perform on a regular basis. Manual testing tends to be quite error prone, leading to situations where consis tently reproducing a bug can be very difficult.
Functional Testing Functional Testing focuses on interactions with an application's user interface (UI) via the mouse, keyboard or other input device with particular attention to how the application visually responds to input. The goal of Functional Testing is to methodically cover all of the various UI features exposed by an application. Functional Testing should be highly organized and structured in a manner that allows for additional tests to easily be incorporated as new features are added.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Overview of Testing and TestComplete
37
Unit Testing Unit Testing is testing that focuses on smaller atomic portions of an application. Typically, Unit Testing requires internal knowledge of how an application performs and seeks t o test portions (objects, methods and function) of an application in isolation. In many cases, applications have to be designed with Unit Testing in mind in order for this type of testing to be truly effective. The benefit of unit testing is that it tends to force application developers to write smaller more well defined routines with fewer dependencies allowing for more highly s pecific tests to be developed.
Regression Testing Regression Testing is the process of executing tests in a repeatable manner and comparing the latest results with previous test executions to ensure that the same outcome is achieved. Regression Testing is extremely important and is the means of realizing the value of test automation. Repeatedly executing tests over time allows you to verify the application is still performing in the manner in which it was intended.
Distributed Testing Distributed Testing is the act of farming different portions of a test out to separate machines for execution. Distributed Testing is useful for simulating real world interactions on a networked application such as a web site or web service and can exercise functionality designed to handle concurrent use of application resources including, but not restricted to data.
HTTP Performance Testing HTTP Performance Testing is the simulation of real-world interactions with a web application from multiple machines. TestComplete provides the ability to leverage networked computers and virtual users to simultaneously submit HTTP transactions to a web application.
Multi-Tier Explained In software development there are typically three Tiers which are used to describe various aspects of an application they are Client Tier, Middle Tier and Data Tier. These are each defined as: Client - The user interface or presentation of an application and it's data which is typically covered through Functional Testing. Data Tier - The storage of an application's data which can be exercised by Functional Testing as well as Unit Testing Middle Tier - Refers to the portion of the application responsible for moving data back and forth between the Client and the Data Tiers. The code that resides in this Tier can be tested from either the Client Tier via Functional testing or through Unit Testing on the code in the Middle Tier itself. Keep in mind that these are not strict rules as to which type of testing should be used but more illustrative how the different types of testing can be used.
3.4
Before You Begin There are a few things you should know before diving into writing test automation using TestComplete or any test automation tool for that matter. In this section, we'll discuss the steps you should take to maximize the utility of your test automation efforts.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
38
TestComplete 7 Made Easy
Communicating Test Results Now you might be thinking "huh? I haven't even started yet and I have to think about communicating my results?" The answer is a resounding YES! Unfortunately, Quality Assurance and test automation specifically, at least in the software world, tends to get a bad rap. Creating solid test automation that can stand up over time and provide valuable ongoing feedback is a difficult task which leads a lot of people (read management) to think time and effort spent working on automation is wasted. To solve this problem you'll want to focus on getting your test results published quickly and consistently to prove that you're efforts are worth the investment. TestComplete provides some facilities for producing log output though you'll want to be sure and iron out your strategy from the start. For example, you may want to setup a web server where you can publish results in fact, TestComplete supports exporting log results to HTML which could be a good starting place.
Plan your testing, but not that kind of planning... The planning we're referring to has to do with your choice of testing tool, TestComplete. Planning sounds like an obvious first task and although it's important to plan in terms of testing an applications features it's also important to plan with respect to the testing facilities available in TestComplete. You should gain a thorough understanding of TestComplete's features before you embark on writing test automation to avoid a situation where you're weeks into test development only to discover a feature that could have saved you numerous hours or days. TestComplete is rich with features that make test automation easier although like any development tool it provides many different ways to solve the same problem. For example, TestComplete has a powerful and indeed almost alluring, recorder making it easy to quickly create automated tests. While a test recorder is a great tool, recorded tests tend to be more brittle than hand written tests because they capture a single iteration at a given point in time and don't take into account unexpected events like an error dialog popping up. The alternative is handwritten tests where you can methodically plan how the test will react in unexpected circumstances. The down side of handwritten tests is they tend to take longer to develop though over the long run they'll likely require less maintenance because of the tendency to design the test more rigorously. That said, it's not a bad idea to start with a recorded script and massage it into what amounts to a handwritten test.
Organizing your TestComplete projects TestComplete provides the ability to customize the Project Items that are included by default on a new project using Project Templates. In order to maintain consistency across your testing organization you should work towards creating a project template(s) that's pre-configured for your test environment. For example, if you're testing a Window 32-bit GUI application, create a Project Template that has the Tested Applications node with your application already added to it. Also, look closely at how you can utilize Aliases to avoid using long dotted object names like: Sys.Process("iexplore").IEFrame(0).Window("WorkerW", "", 1).Window( "ReBarWindow32", "", 1).Window("ComboBoxEx32", "", 1).Window( "ComboBox", "", 1).Window("Edit", "", 1)
In TestComplete 7, a new automatic NameMapping feature has been added to make this even easier.
Use a Source Control Repository TestComplete is a development tool and as such the projects, scripts, data, etc. used in your tests should be kept under version control. If this is something you're already doing, skip ahead. If not, you should consider version control the next priority and work t o get your test suites under version control. There are
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Overview of Testing and TestComplete
39
lots of options including some ex cellent Open Source projects which are freely available like Subversion, otherwise known as SVN. While it's beyond the scope of this document to discuss the specific merits of source control it's a subject that shouldn't be ignored.
3.5
Your Most Important Test Arguably, the first test you should focus on is a "smoke test". In this section we'll discuss what a smoke test is and provide guidance as to how to construct the test in such a way as to maximize its effectiveness.
Creating a Smoke Test Probably the most important test you'll write is your smoke test, at least it should be. Typically, the goal of a smoke test is to verify that the latest build delivered to QA is either worth further consideration or DOA (dead on arrival). The smoke test is crucial because of the time savings it can provide both R&D and QA. A good smoke test should: ·
·
Run quickly - a smoke test should not last for hours but minutes and test the most crucial functionality Fail quickly - as soon as a failure is detected in the smoke test should end and trigger a failure notification
·
Cover a broad range of functionality, focusing on breadth not depth
·
Require minimal s etup/configuration of the application under test
·
Be setup to run against every build
·
Adapt over time as the application under test evolves
·
Serve as a model for new test automation
If you take the time to organize your smoke test to cover these goals you will undoubtedly save time and resources over the long run. Your smoke test should serve as an model that embodies your "best practices" from which your QA team can draw from for their own tests. If you've never written a smoke test before, start small. In the beginning simply get the s moke test to verify even a single piece of functionality consistently. Over time, work to increase its coverage but remain focused on the quality of the test. It's unacceptable to have a smoke test that can't run consistently and without problems.
Executing your Tests Regularly Once your smoke test is written and under version control the next step is to automate its execution. AutomatedQA has a product called Automated Build Studio which can automate your TestComplete tests and trigger them to execute when a new build is delivered to QA, a process called Continuous Integration or CI. In addition to Automated Build Studio there are Open Source CI servers such as CruiseControl.NET. The main benefit of a CI server is to reduce the amount of time it takes to execute your test automation as well as ensure that it executes against every build. By setting up a CI server you can not only alleviate your QA engineers from having to manually execute their tests but you'll quickly identify tests that are unable to consistently run to completion and may require closer scrutiny. In addition, many CI servers include a means of publishing test results providing for great visibility into the automation efforts.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
40
3.6
TestComplete 7 Made Easy
Summary To best leverage your investment in test automation it's important t o plan your overall testing strategy. Before diving in and unleashing the full power of TestComplete be sure to organize your communication strategy. Make communicating your results an important part of judging the success of your efforts. Also, treat your test development like any other software development project and use the tools available to maintain the quality and integrity of your test code.
Remember the Goal Ultimately, the goal of test automation is to save time, money and improve quality. Test automation can relieve you of the task of manually testing existing functionality allowing you to focus attention on areas not already covered by automation. However, that statement is only true as long as your existing test automation is working, being executed consistently and the results are clearly communicated to the people who need them.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
Part
IV TestComplete IDE
42
TestComplete 7 Made Easy
4
TestComplete IDE
4.1
Objectives This section introduces the basic tools you need to work effectively with TestComplete. In this section you will:
4.2
·
Get familiar with the TestComplete environment.
·
Locate the Menus, Toolbars, Workspace areas, Object Browser and Project explorer.
·
Gain a solid understanding of the Object Browser.
·
Get familiar with the TestComplete Code Editor and all its features.
·
Gain the necessary knowledge of debugging in the TestComplete Editor.
Menus and Toolbars TestComplete Menus The TestComplete menus are no different from many Integrated Development Environments menus. From the figures below, you can see the File , Edit, View , Script, Tools and Help menus.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
TestComplete IDE
43
TestComplete Toolbar The TestComplete Toolbar is an easy way to get at TestComplete functionality or deeper menu items with only one click. Saving files, adding new units, recording, playing back, debugging, searching, formatting, etc...
The great thing about the toolbar is that it is customizable. So if you ever use a TestComplete functionality often and you don't see it on the toolbar, add it by right clicking on the toolbar and choose customize. Click on the Commands tab and drag any functionality you desire to anywhere on the toolbar. Once you drag a
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
44
TestComplete 7 Made Easy
command to the toolbar, the icon is persisted there permanently.
4.3
Panels and Workspaces
4.3.1
Project Explorer The TestComplete IDE as you might expect consists of several pluggable windows that facilitate project management, code management, debugging, object browsing, main script and result logs workspaces.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
TestComplete IDE
The Project Workspace consists of two main windows, The Project Explorer and the Code Explorer .
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
45
46
TestComplete 7 Made Easy
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
TestComplete IDE
47
The Project Explorer will allow you to see all projects in a suite and all the specific Project Items that are part of a specific Project. If you ever missed a Project Item from the Wizard at startup, y ou can always right click on a Project in the Project Explorer and choose Add New Item, where you will be presented with all TestComplete Project plug-ins to add to the project. The Code Explorer on the other hand, is a different view into your code base that enables you to navigate easily between functions in large files, rename functions, delete functions, sort functions by name in the tree, etc...
4.3.2
Object Browser The Object Browser is the most powerful part of TestComplete. It is where all the brains behind the TestComplete muscle reside. When you click on the Object Browser Window in TestComplete, the engine monitors all running processes on your machine and extracts vital information about each process for display as you can see below. You
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
48
TestComplete 7 Made Easy
can filter the kind of processes you need to inspect or eliminate a category of processes by right-clicking on the Object Tree below on the left and filter processes. The Object Browser can also examine your system as a hardware unit and report on the CPU, CPU count, amount of memory (RAM) on t he machine, operating sys tem in use, and other useful information, from a testing perspective.
4.3.2.1
Process Tree Pane
The Process Tree Pane enables you to view all currently running processes on the machine and its toolbar on top allows you to filter the processes from running application to system processes to chosen testapps applications in your TestComplete project.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
TestComplete IDE
49
By Right clicking anywhere in the Object Tree Pane, the popup menu appears with options to refresh the content of the tree, filter, terminate, copy to editor, sort and other useful functionality that we will discuss later in this chapter.
Copyright © 2009 AutomatedQA Corp. - 2.0 Release