Acrobat PDF

testcomplete-made-easy-book

You must be logged in to download this document
Reviews
Shared by: mudita sharma
Categories
Tags
Stats
views:
571
downloads:
41
rating:
not rated
reviews:
0
posted:
8/4/2008
language:
English
pages:
0
TestComplete Made Easy by Lino Tadros - Falafel Software Inc. Welcome to TestComplete Made Easy, the new guide to TestComplete, the award winning automated testing tool from AutomatedQA Corp. We hope you enjoy the book as much as we, at Falafel Software, enjoyed creating it. Download the latest version of this book and the example source files: http://www.automatedqa.com/testcomplete-book Lino Tadros President & CEO Falafel Software Inc. www.falafel.com TestComplete Made Easy Copyright © 2008 AutomatedQA Corp. - 1.0 Release All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, or mechanical, including photocopying, recording, taping, or information storage and retrieval systems - without the written permission of the publisher. Products that are referred to in this document may be either trademarks and/or registered trademarks of the respective owners. The publisher and the author make no claim to these trademarks. While every precaution has been taken in the preparation of this document, the publisher and the author assume no responsibility for errors or omissions, or for damages resulting from the use of information contained in this document or from the use of programs and source code that may accompany it. In no event shall the publisher and the author be liable for any loss of profit or any other commercial damage caused or alleged to have been caused directly or indirectly by this document. Printed: July 2008 Publisher AutomatedQA Corp. Authors Alain "Lino" Tadros Eric Holton Steve Trefethen Technical Editors Noel Rice Drew Wells Cover Designer Matt Kurvin Team Coordinator Noel Rice Production Falafel Software Inc. Special thanks to: All the team members at AutomatedQA worldwide for creating a magnificant piece of software in TestComplete. The authors also would like to thank the Falafel team members in Colorado, Texas, California and Washington for their feedback, guidance and recommendation 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. Falafel would also like to thank Mr. Bobby Edgar for his continuous support during the training summits and for being a great friend to Falafel for many years. Last but not least, thank you to all our families for their support and patience while we wrote the book 4 TestComplete Made Easy Table of Contents Foreword 9 Part I Introduction 1 Introduction to TestComplete ................................................................................................................................... 2 Who Should Read this Book ................................................................................................................................... 3 What Do................................................................................................................................... You Need to Have Before You Read this Book? 4 What Do................................................................................................................................... You Need to Know Before Reading this Book? 5 How the ................................................................................................................................... Book is Organized 11 11 11 12 13 13 Part II AutomatedQA 1 History ................................................................................................................................... 2 Product ................................................................................................................................... Offerings 17 17 17 Part III Overview of Testing and TestComplete 1 Objectives ................................................................................................................................... 2 Terminology ................................................................................................................................... 3 Types of................................................................................................................................... Testing 4 Before You Begin ................................................................................................................................... 5 Your Most Important Test ................................................................................................................................... 6 Summary ................................................................................................................................... 23 23 23 23 24 26 26 Part IV TestComplete IDE Environment 1 Objectives ................................................................................................................................... 2 Menus and Toolbars ................................................................................................................................... 3 Panels and Workspaces ................................................................................................................................... Project Explorer Object Browser 29 29 29 31 .......................................................................................................................................................... 31 .......................................................................................................................................................... 33 Process Tree Pane ......................................................................................................................................................... 34 Object Properties Pane ......................................................................................................................................................... 36 Object Recognition ......................................................................................................................................................... 42 Introduction Editor Bookmarks Debugging Call Stack Locals Watch List ......................................................................................................................................... 42 White-Box Applications ......................................................................................................................................... 43 .......................................................................................................................................................... 46 ......................................................................................................................................................... 47 ......................................................................................................................................................... 50 ......................................................................................................................................... 50 ......................................................................................................................................... 51 ......................................................................................................................................... 52 ......................................................................................................................................... 53 Code Completion ......................................................................................................................................................... 46 Editor Options ......................................................................................................................................................... 48 Breakpoints 4 Summary ................................................................................................................................... 57 Copyright © 2008 AutomatedQA Corp. - 1.0 Release Contents 5 Part V Projects and Suites 1 Objectives ................................................................................................................................... 2 Project Anatomy ................................................................................................................................... 3 New Project Wizard ................................................................................................................................... 4 Hands on Lab: Create a Simple Test ................................................................................................................................... 5 Summary ................................................................................................................................... 59 59 59 62 64 65 Part VI Project Items 1 Objectives ................................................................................................................................... 2 Project Items ................................................................................................................................... 3 Summary ................................................................................................................................... 67 67 67 70 Win32 Tested Applications .......................................................................................................................................................... 68 Part VII Test Log 1 Objective ................................................................................................................................... 2 Script Log ................................................................................................................................... 3 Emailing................................................................................................................................... Result 4 LockEvents ................................................................................................................................... 5 Summary ................................................................................................................................... 72 72 72 73 74 75 Part VIII Named Mappings 1 Objectives ................................................................................................................................... 2 Map to Object ................................................................................................................................... 3 Highlight Objects ................................................................................................................................... 4 Mapping................................................................................................................................... Dialog 5 Aliases in Scripts ................................................................................................................................... 6 Summary ................................................................................................................................... 77 77 77 86 88 89 89 Part IX Unit Testing 1 Objectives ................................................................................................................................... 2 Supported Unit Testing Types ................................................................................................................................... 3 NUnit Example ................................................................................................................................... 4 Hands on Lab: Running a Unit Test ................................................................................................................................... 5 Summary ................................................................................................................................... 91 91 91 92 95 97 Part X Manual Testing 1 Objectives ................................................................................................................................... 2 Setting up a Manual Test Project ................................................................................................................................... 3 Hands on Lab: Create a Manual Test ................................................................................................................................... 4 Hands on Lab: Scripting and Manual Testing ................................................................................................................................... 99 99 99 100 107 Copyright © 2008 AutomatedQA Corp. - 1.0 Release 5 6 TestComplete Made Easy 5 Summary ................................................................................................................................... 111 Part XI Basic Record and Playback 1 Objectives ................................................................................................................................... 2 Overview ................................................................................................................................... 3 Recording Toolbar Anatomy ................................................................................................................................... Adding Text Pausing Stopping 113 113 113 114 .......................................................................................................................................................... 115 .......................................................................................................................................................... 117 .......................................................................................................................................................... 117 Changing Recording Types .......................................................................................................................................................... 116 4 Hands on Lab: Perform a Basic Recording ................................................................................................................................... 5 Summary ................................................................................................................................... 117 118 Part XII Low Level Procedure 1 Objectives ................................................................................................................................... 2 Recording ................................................................................................................................... 3 Hands on Lab: MS Paint Test ................................................................................................................................... 4 Summary ................................................................................................................................... 120 120 120 123 127 Part XIII Stores and Checkpoints 1 Objectives ................................................................................................................................... 2 Region ................................................................................................................................... Comparisons 3 Files Comparisons ................................................................................................................................... 4 Object Comparisons ................................................................................................................................... 5 Hands on Lab: Comparing File, Picture and a Property ................................................................................................................................... 6 Summary ................................................................................................................................... 129 129 129 133 136 138 145 Part XIV Data-Driven Testing 1 Objectives ................................................................................................................................... 2 Overview ................................................................................................................................... 3 Modifying Scripts ................................................................................................................................... 4 Hands on Lab: Modifying Recording for Data-Driven Testing ................................................................................................................................... 5 Summary ................................................................................................................................... 147 147 147 147 149 152 Part XV Event Handling 1 Objectives ................................................................................................................................... 2 General Events Definition ................................................................................................................................... OnLogError 154 154 154 157 158 162 .......................................................................................................................................................... 156 3 Unexpected Windows ................................................................................................................................... 4 Hands on Lab: Create Unexpected Window Handler ................................................................................................................................... 5 Summary ................................................................................................................................... Part XVI Working with Databases 164 Copyright © 2008 AutomatedQA Corp. - 1.0 Release Contents 1 Objectives ................................................................................................................................... 2 ADO 3 BDE ................................................................................................................................... ................................................................................................................................... 7 164 164 166 166 174 4 Hands on Lab: Query Database ................................................................................................................................... 5 Summary ................................................................................................................................... Part XVII Web Page Testing 1 Objectives ................................................................................................................................... 2 Web Page Model ................................................................................................................................... 3 Naming................................................................................................................................... Conventions 4 Web Comparison Checkpoint ................................................................................................................................... 5 Web Accessibility Checkpoint ................................................................................................................................... 6 Finding................................................................................................................................... Web Page Elements 7 Dynamic HTML ................................................................................................................................... 8 Hands on Lab: Work with Web Pages ................................................................................................................................... 9 Summary ................................................................................................................................... 176 176 176 177 177 180 183 185 188 197 Part XVIII WebServices Testing 1 Objectives ................................................................................................................................... 2 Testing................................................................................................................................... against WSDL 3 WebServices Checkpoint ................................................................................................................................... 4 WebServices Testing Dialogs ................................................................................................................................... 5 XML Checkpoint ................................................................................................................................... 6 Hands on Lab: Testing a SOAP 1.2 Web Service ................................................................................................................................... 7 Summary ................................................................................................................................... 199 199 199 204 209 211 213 220 Part XIX HTTP Performance Testing 1 Objectives ................................................................................................................................... 2 Performance Testing Your Web Applications ................................................................................................................................... 3 HTTP Load Testing Options ................................................................................................................................... 4 Cookie ................................................................................................................................... Handling 5 Recording ................................................................................................................................... 6 Connections, Requests and Responses ................................................................................................................................... 7 Visual Creation of a Load Test ................................................................................................................................... 8 Analysis of the Test Log ................................................................................................................................... 9 Modifying HTTP Traffic ................................................................................................................................... 10 Hands on Lab: Working with HTTP Traffic ................................................................................................................................... 11 Summary ................................................................................................................................... 222 222 222 222 224 224 227 228 230 232 234 237 Part XX Remote Agent 1 Objectives ................................................................................................................................... Copyright © 2008 AutomatedQA Corp. - 1.0 Release 239 239 7 8 TestComplete Made Easy 2 Installing Remote Agent ................................................................................................................................... 3 Running Remote Agent ................................................................................................................................... 4 Configuring Remote Agent ................................................................................................................................... 5 Hands on Lab: Working with Remote Agent for HTTP Load Testing................................................................................................................................... 6 Summary ................................................................................................................................... 239 239 241 243 247 Part XXI Distributed Testing 1 Objectives ................................................................................................................................... 2 Network Suites ................................................................................................................................... 3 Hosts ................................................................................................................................... 4 Jobs/Tasks ................................................................................................................................... 5 SynchPoints ................................................................................................................................... 6 Setup ................................................................................................................................... 7 Summary ................................................................................................................................... 249 249 249 251 252 253 253 260 Part XXII User Forms 1 Objectives ................................................................................................................................... 2 Creating ................................................................................................................................... 3 Scripting ................................................................................................................................... 4 Summary ................................................................................................................................... 262 262 262 264 264 Part XXIII Best Practices 1 General ................................................................................................................................... 2 Web Page ................................................................................................................................... 266 266 268 Part XXIV Cheat Sheet 1 Keyboard Shortcuts ................................................................................................................................... 2 Code Completion ................................................................................................................................... 3 Keyboard Handling in Recorder ................................................................................................................................... 4 Global Shortcuts/Changing Keyboard Emulation ................................................................................................................................... 270 270 272 273 274 Part XXV Professional Offering Index 278 280 Copyright © 2008 AutomatedQA Corp. - 1.0 Release Foreword 9 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 © 2008 AutomatedQA Corp. - 1.0 Release Part I Introduction Introduction 11 1 1.1 Introduction 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 non-developers, 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 ability 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 1.2 Who Should Read this Book You should read this book if: Copyright © 2008 AutomatedQA Corp. - 1.0 Release 12 TestComplete Made Easy · 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. 1.3 What Do You Need to Have Before You Read this Book? This book was written for TestComplete 6.x. Minimum System Requirements Ø Intel Pentium II 400 MHz or higher (Pentium III 800 MHz recommended). Ø Microsoft Windows 98, Windows ME, Windows 2000, Windows XP (both 32-bit and 64-bit editions), Windows Vista (both 32-bit and 64-bit editions), Windows Server 2003 (both 32-bit and 64-bit editions) or Windows NT 4.0 with Service Pack 6 or later. Important: If you use a computer that has several processors or a multiple-core processor (for example, dual-core CPU) and has Windows XP Service Pack 2, then you must install the Windows update #896256 in order for TestComplete to be able to record user actions correctly. The update is available on Microsoft’s web site: http://support.microsoft.com/kb/896256 Ø Microsoft Internet Explorer 5.0 or later. Ø Memory: 128MB of RAM (256MB or more recommended). Ø 250MB hard disk space. Ø VGA or higher resolution monitor. Ø Mouse or other pointing device. Additional Requirements Ø To test Java Open Applications, you must have one of the following Java virtual machines installed on your computer: o MSVM, build 3309 or later. o Sun JDK (or JRE) v. 1.1.8 or later. o BEA JRockit 5.0. Ø To test .NET Open Applications, the Microsoft .NET Framework v. 1.0.3705 or later is required. Ø To execute TestComplete tests from test projects created in Microsoft Visual Studio 2005, Microsoft Visual Studio 2005 Team Suite ver. 8.0.50727.42 or later or Microsoft Visual Studio 2005 Team Edition for Software Testers ver. 8.0.50727.42 or later are required. Ø To install TestComplete’s Microsoft Visual Studio 2005 Team Foundation Integration package, Microsoft Visual Studio 2005 Team Foundation Server Release is required. Ø To perform load testing of web servers, Microsoft Windows 2000, Window XP, Windows Vista, Windows Server 2003 or Windows NT with Service Pack 6.0 or later is required. Also, it is recommended that your computer meets the following requirements: · Minimal Configuration Copyright © 2008 AutomatedQA Corp. - 1.0 Release Introduction 13 o Intel Pentium III 800 MHz o 256 of RAM (for 300 virtual users) · Recommended Configuration o Intel Pentium 4 3 GHz with HyperThreading o 1 Gb of RAM 1.4 What Do You Need to Know Before Reading this Book? TestComplete is a development environment, complete with an IDE (Integrated Development Environment) and programming languages. In this course you will not be simply clicking a few buttons and automatically recording your tests. Expect to perform development work, i.e. working with the IDE, writing script and working with relatively complex test configurations. The training is based on Windows platform testing. Although the product is capable of using 5 different scripting languages, the source code for the book is written in VBScript and JScript. This manual is used in TestComplete training classes along with lectures and hands-on lessons to give students a rich learning environment. When this material is presented in the classroom, the format is 50% lectures and 50% hands-on labs. While a printed manual can't reproduce the experience of listening to and working with a skilled trainer, it was written by those same trainers and we've done our best to make the text in this book an acceptable stand-in for the lectures. The chapter text (or lectures if we're lucky enough to be in class together) will provide you with the background knowledge on testing and TestComplete. The hands-on labs will provide the practical skills required to handle real-world testing scenarios and they are reproduced here exactly as they are presented in the classroom. 1.5 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 discusses 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 Environment 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. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 14 TestComplete Made Easy Project Items This section provides an overview of all project item types with additional detail on the Win32 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. Named Mappings This section introduces Named Mappings and Aliases used to handle long object identifiers and to provide identifiers with meaningful names. Unit Testing 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 compare various testing input including visual areas of the screen, files and objects. Data-Driven Testing This section covers how the Data Driven Testing plug-in consumes common data types. 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 external databases. This section explains the connectivity options, how to connect and run queries during a test. Web Page Testing Copyright © 2008 AutomatedQA Corp. - 1.0 Release Introduction 15 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 testing and other types of performance testing (e.g. load, stress, scalability). You will also learn about HTTP traffic recording and modification. 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 script 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, keyboard handling in the recorder, how to change global shortcuts and how to change keyboard emulation. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Part II AutomatedQA AutomatedQA 17 2 2.1 AutomatedQA History AutomatedQA offers software products and services for development and quality assurance projects worldwide. They create innovative, award-winning and affordable products for the entire software development lifecycle including TestComplete for test automation and AQtime, a sophisticated performance and memory profiler. AutomatedQA has an impressive list of customers ranging from huge teams in the world's largest organizations to progressive one-developer shops. AutomatedQA was founded in 1999 with headquarters in Las Vegas, Nevada, United States. AutomatedQA’s guiding principle is to be wholly focused on providing affordable and feature-rich developer tools and quality assurance technologies, and on providing users with fast and accurate product support each and every day. What does affordable and feature-rich mean? It means bang for the buck. It means that their solutions tend to cost a fraction of their competitor's prices and offer more features. A good example is their automated testing tool, TestComplete. Some of their competitors charge separately for different test types like GUI testing, unit testing and load testing. TestComplete includes all supported testing types in one product with more features, for considerably less. It’s this combination of affordability and features that led Joel Spolsky, of joelonsoftware.com to write, “AutomatedQA's TestComplete is a great product and just as capable as the market leader at less than one-tenth the price. Why would anybody pay $6000 per seat for test automation?”. -- Joel Spolsky As a side note, AutomatedQA first customer ever in 1999, was no other that Falafel Software's QA Master, Mr. Eric Holton. 2.2 Product Offerings AutomatedQA offers several products in the Software Application LifeCycle Management sector. This include TestComplete, AQtime, Automated Build Studio, AQdevTeam and other derivatives of the main products like TestExecute, TestRecorder and AQtime for Linux. AQtime Debug, Optimize, and Deliver Rock Solid Applications AQtime is AutomatedQA's award-winning performance profiling and memory and resource debugging toolset for Microsoft, Borland, Intel, Compaq and GNU compilers. The latest version of AQtime, AQtime 5, includes dozens of productivity tools that help you easily isolate and eliminate all performance issues and memory/resource leaks within your code by generating comprehensive and detailed reports for your .NET and Windows applications. AQtime supports .NET 1.0, 1.1, 2.0, 3.0 applications and Windows 32- and 64-bit applications. AQtime is built with one key objective - to help you completely understand how your programs perform during execution. Using its integrated set of performance and debugging profilers, AQtime collects crucial performance and memory/resource allocation information at runtime and delivers it to you both in summarized and detailed forms, with all of the tools you need to begin the optimization process. This is all done without modifying the application's source code! With AQtime's intuitive and user-friendly interface and instrumentation in hand, you will quickly know the exact speed, memory usage, and application usability issues in your programs. As you Copyright © 2008 AutomatedQA Corp. - 1.0 Release 18 TestComplete Made Easy optimize and improve your code, AQtime provides all the tools to compare and merge results so that over time, an exact and accurate "picture" of your application's state takes shape: · Monitor and report on all areas that could degrade your project’s performance and quality. · Assess the thoroughness of your tests by using Coverage Profiling. · Ensure that you make the right code improvements from day one. · Helps drill down to the exact line of source code that is responsible for performance or memory allocation inefficiencies. Automated Build Studio Automate Software Builds, Tests and Deployment In the current state of software development, with projects becoming more and more complex, building, testing and releasing of software projects consumes an ever-increasing amount of time and resources. Automated Build Studio is a powerful build and release management system that provides an easy way to automate the software development build, test and release processes. Its intuitive interface and Copyright © 2008 AutomatedQA Corp. - 1.0 Release AutomatedQA 19 unprecedented flexibility allows even inexperienced users to create complex visual macros which can automate repetitive or day-to-day tasks with the single click of a button. Even though the product name includes the word “build”, you can use Automated Build Studio to automate any common or everyday tasks in your organization. Automated Build Studio contains over 540 built-in operations that will help you: · Compile applications · Create installation packages · Perform automated builds as scheduled tasks · Get and put files from/into version control systems · Label sources in version control systems · Compile help files · Create, modify and delete registry keys and INI file settings · Copy and move files to a location (network drive, Web site, FTP server, etc.) · Extract and pack files from/to ZIP and RAR archives · Run automated test scripts and profilers · Post bug reports to issue-tracking systems · Send and receive e-mail, ICQ and newsgroup notifications · Burn CDs and DVDs · Register COM and .NET components · Perform scripting operations in any of 3 scripting languages (VBScript, Jscript or DelphiScript) or many other operations... With Automated Build Studio you can: · Automate your software builds · Perform distributed builds · Automate the process of application testing and profiling. · Create deployment packages and write them to CD and/or DVD. · Automate back-up processes. · Automate data and system consistency checks (for example, you can automate checking the free disk space or the availability of a Web service). Copyright © 2008 AutomatedQA Corp. - 1.0 Release 20 TestComplete Made Easy TestExecute TestExecute allows you to execute scripts written with TestComplete and log test results on machines that do not have TestComplete installed - using a simple, resource friendly command-line utility. TestExecute gives QA departments the ability to test applications in real life user environments - such as at customer sites - without the need to install TestComplete on the target machine. Copyright © 2008 AutomatedQA Corp. - 1.0 Release AutomatedQA 21 TestRecorder TestRecorder is a set of runtime libraries to be distributed with your 32-bit and 64-bit applications. Once incorporated into your app, TestRecorder fully records end-user actions in the binary format. Later, the recorded data can be converted with TestComplete to an easily readable script code in VBScript, Jscript, DelphiScript, C++Script or C#Script. These scripts tell you exactly what a user was doing during application execution - allowing you to accurately repeat the sequence of user actions via TestComplete or TestExecute. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Part III Overview of Testing and TestComplete Overview of Testing and TestComplete 23 3 3.1 Overview of Testing and TestComplete 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: · 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. 3.2 Terminology First, let's define a few terms to help facilitate a discussion on testing: · 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 3.3 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 the 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 consistently 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 © 2008 AutomatedQA Corp. - 1.0 Release 24 TestComplete Made Easy 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 to 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 specific tests to be developed. Regression Testing Regression Testing is 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. Communicating Test Results Copyright © 2008 AutomatedQA Corp. - 1.0 Release Overview of Testing and TestComplete 25 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 Win32 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) 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 to get your test suites under version control. There are lots of options including some excellent 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. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 26 TestComplete Made Easy 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 setup/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 smoke 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. 3.6 Summary To best leverage your investment in test automation it's important to plan your overall testing strategy. Before diving in and unleashing the full power of TestComplete be sure to organize your communication Copyright © 2008 AutomatedQA Corp. - 1.0 Release Overview of Testing and TestComplete 27 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 © 2008 AutomatedQA Corp. - 1.0 Release Part IV TestComplete IDE Environment TestComplete IDE Environment 29 4 4.1 TestComplete IDE Environment Objectives This section introduces the basic tools you need to work effectively with TestComplete. In this section you will: · 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. 4.2 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 © 2008 AutomatedQA Corp. - 1.0 Release 30 TestComplete Made Easy 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 command to the toolbar, the icon is persisted there permanently. Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 31 4.3 4.3.1 Panels and Workspaces 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. The Project Workspace consists of two main windows, The Project Explorer and the Code Explorer. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 32 TestComplete Made Easy Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 33 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, you 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 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 the machine, Operation system is use, and other useful information, from a testing perspective. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 34 TestComplete Made Easy 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 © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 35 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 © 2008 AutomatedQA Corp. - 1.0 Release 36 TestComplete Made Easy 4.3.2.2 Object Properties Pane From the Object Tree Pane, invoke the 3rd menu option from the top called Object Properties..., that will invoke the following dialog when you need to quickly dissect a window on the screen. Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 37 As a Lab for this part of the chapter, let's use the Object Browser, Object Tree Pane and Object Properties dialog to work with a Notepad window: 1. Open Notepad from the Windows directory or System32, depending of the version of Windows you are running. 2. View the Object Browser in TestComplete to determine that the process of Notepad has been detected by the Object Tree. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 38 TestComplete Made Easy Notice that the process of Notepad is displaying three windows underneath the process and the Properties of the process itself are displayed on the right. The main Notepad window is actually the 3rd one down. The other two windows (IME and MSCTFIME UI) are other non-visible windows in Notepad for language direction reasons like Hebrew and Arabic, etc... 3. To make sure that the main window of Notepad is the 3rd one underneath the process, right click on it and choose Highlight on the Screen. Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 39 Note: The Notepad application is brought to the front and the main window starts flashing with a red rectangle around the main window several times. 4. Notice in the Properties window that most of the properties have a blue color arrow next to them. That means these properties are READ-ONLY as far as the Object Browser is concerned. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 40 TestComplete Made Easy 5. One of the properties of that main window in Notepad is called "WndCaption" and it does not have the blue arrow next to it. That means it can be written to from the Object Browser. This property is actually the title of the window. Push the CTRL key and click inside of the edit area of the property. 6. Type "Welcome to TestComplete Training" and press [Enter]. 7. Now go back to the Notepad application and view the title area of the application. Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 41 Don't worry, you did not change Notepad forever :) it is only for this session until it is shutdown and started up again. 8. Now let's use the Finder tool to capture the Edit window in Notepad (The white area only with no Notepad title or menus). 9. Invoke the Object Properties dialog from the popup menu of the Object Tree. Drag the Finder tool to the white area in Notepad until you see a red rectangle around the edit portion only. 10.The Object Properties will automatically refresh and show all the properties TestComplete was able to see from the Window object in memory. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 42 TestComplete Made Easy The button pointed to by the number 1 above will allow you to highlight the window object in-place in the Object Tree Pane as part of the Object Browser. This is a very handy button when your application windows are numerous and have a deep hierarchy as is the case for Internet Explorer. The button pointed to by number 2 above will allow you to highlight the object on the screen by flashing it several times, similar to step 3 above. 4.3.2.3 Object Recognition 4.3.2.3.1 Introduction From the previous sample with Notepad, you probably noticed that TestComplete recognized a lot of properties of the main Notepad window as well as the Edit window. On the other hand, you probably also noticed that the Fields and Events tab were blank. Even the Methods tab had only methods pertaining to standard TestComplete functionality and actions. So where is Notepad own methods, Fields and events? Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 43 Well, TestComplete will recognize objects and will go as deep as the application will allow it to. That means, it is based on how the application was built, developed or compiled as to what TestComplete will be able to see inside of it. This brings up the topic of White Box Applications Vs. Black Box Applications. TestComplete will be able to automatically see deeply inside .NET and Java application without any changes to the application just because of the nature of metadata generation of .NET and Java application which are easy to reflect. Reflection is the ability to retrieve internal objects, properties, methods and events. So these are always called White Box Applications. Some Applications are written in C, C++ or Delphi, these applications are mainly Black Box applications but could be compiled in such a way to enable them to become White Box Applications. That would require compiling with Debug information enabled and the inclusion of some TestComplete files into the project to enable reflection of all program metadata. 4.3.2.3.2 White-Box Applications While viewing the Object Browser, you will notice sometimes that a TestComplete icon will show next to a specific process. That sign identifies the process as "OPEN" and means TestComplete can reflect its content and get as much Runtime Type Information as possible. In this sample, I used Visual Studio 2008 to generate a very simple C# based Windows application that adds two numbers together Copyright © 2008 AutomatedQA Corp. - 1.0 Release 44 TestComplete Made Easy The only line of code in this example is: private void btnAddition_Click(object sender, EventArgs e) { TxtResult.Text = (Convert.ToInt32(TxtNumberOne.Text) + Convert.ToInt32(TxtNumberTwo.Text)).ToString(); } In case you don't have Visual Studio, the executable is available through the book download as "TCDotNetApp.exe". Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 45 Notice that TestComplete automatically figured out that we are dealing with a .NET application so it started using the built in "WINFORMSOBJECT" identifier to make it easier to reach all .NET methods, fields, events and properties associated with the application. At this point, if we had a function in the TCDotNetApp.exe called "Hello" that was never called from the User Interface, it will still show up in the Methods tab. We would be able to call it directly from the script and it will be visible to TestComplete via reflection. Note: TestComplete has many built in recognition objects for Delphi VCL objects, Java Swing objects, XAML WPF objects and others... Copyright © 2008 AutomatedQA Corp. - 1.0 Release 46 TestComplete Made Easy 4.3.3 4.3.3.1 Editor Code Completion The Code Editor in TestComplete is easy to use and productive to get the job done. One of the first features you will discover and love in the TestComplete Editor is the Code Completion feature. I am not sure how we used to write code before this feature was introduced in major development tools and in TestComplete. Instead of having prior knowledge of the objects you need to deal with in TestComplete or have access to the Help files, it is simple enough to let TestComplete do the job for you by entering the name of an object and placing a "." a period after the object. That will invoke the Code Completion window with all properties, methods and events available for that object. Sometimes you even have the need to invoke the Code Completion window in the middle of a statement. That is possible using the handy keyboard shortcut CTRL-SPACE. Another great feature of the TestComplete Editor is the Parameter Completion feature. For example, when you need to know the count and type of a parameter that TestComplete recognizes, you can always open a parenthesis and key in CTRL-SHIFT-SPACE to bring up the Parameter completion window: Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 47 4.3.3.2 Bookmarks Another great feature of the editor in TestComplete is the ability to place bookmarks in script units opened in the IDE and be able to jump between them by a simple keystroke. You can set a bookmark by having the cursor on that line and pressing CTRL - SHIFT - and a number between 1 and 9. In the figure above, please notice that the bookmarks are set on lines 5,15 and 18 (see the yellow glyph in the gutter). Also, the Bookmarks window at the bottom of the editor will list all set bookmarks with their numbers, their unit names and their line numbers. To jump to a specific Copyright © 2008 AutomatedQA Corp. - 1.0 Release 48 TestComplete Made Easy bookmark at any time, press CTRL - 0 to 9 (without the SHIFT). To delete a bookmark, delete from the bookmark window or press CTRL-SHIFT- 0 to 9 again while the cursor is on the bookmark. 4.3.3.3 Editor Options From Tools | Options, you can get to the Editor options under Panels | Code Editor: Under Display, you have the choice to change the Text specifications, background colors and margin, gutter styles and capacity and also whether you want to show line numbers or not. Another very useful feature of the editor in TestComplete is the ability to set Code Templates. Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 49 Every Scripting language has it own templates. Above you will see that I added a new Template called TCTraining that contains a function name "test" with a comment in it. The script itself can be anything that you expect to use a lot in your testing. Notice also the little pipe "|" sign inside the brackets. The pipes indicates the position of the cursor in the code after the template has been inserted. Now lets go back to the editor and try to enter this template: 1. Choose an empty are between two function and press CTRL - J. The following code template helper will appear: Copyright © 2008 AutomatedQA Corp. - 1.0 Release 50 TestComplete Made Easy 2. Choose the TCTraining Template from the list and press Enter. The code is inserted in the script unit and the cursor is blinking right before the comment starts. 4.3.3.4 Debugging 4.3.3.4.1 Breakpoints The Debugger capabilities in the TestComplete's Editor are very helpful in finding script errors, flow problems and also to evaluate the values of local and global variables. Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 51 The Breakpoints window in TestComplete is very easy to use. You can set breakpoints in your editor by clicking in the gutter next to the line you want to set a breakpoint on or by pressing F5 while the cursor is on that line. In the Breakpoints window you can: · Enable or disable a specific breakpoint. That is better than deleting them and reentering them all over based on different debug sessions. · View the Location of the unit name it resides in and also the line number of where it resides. · Include a description to explain the goal behind using the breakpoint. · Finally, you have two powerful features in the breakpoints window which are Pass Count and Condition. If you are debugging a "For Loop" that goes on for 1000 iterations, knowing that it will fail some time after 900 times, it would be wise to place a Pass Count of 900 on the breakpoint instead of having to step over the breakpoint 900 times. When the pass count is not known but a condition has to be met, the Condition property can be set (e.g: x > 100). 4.3.3.4.2 Call Stack The Call Stack window is very helpful when your scripts get called one from the other in a long chain of execution. During a break in execution, the Call Stack window will show the order of execution for the Copyright © 2008 AutomatedQA Corp. - 1.0 Release 52 TestComplete Made Easy calling functions to get to that point of execution. The figure below shows the Call Stack at a break in execution. Usually that is good information for pinpointing the offending procedure. Unfortunately, in many cases "X" does not mark the spot like an Indiana Jones' movie, so the problem you are trying to figure out has already manifested itself way before the break in execution occurred. These are tougher bugs to figure out. 4.3.3.4.3 Locals The Locals window is an easy and fast way to monitor the value of local variable inside of a specific function. Like in the figure below, we created 2 local variables, "myString" and "myNumber", and assigned specific values to both. To view their values, you only need to open the Locals window and they will be there as long as you are breaking inside of the function that contains them. So how do you view values of variables that are not local to a function? That is the functionality of the Watch List. Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 53 4.3.3.4.4 Watch List Notice in the screenshot below that the Global variable "myGlobal" did not show up in the locals window. This is correct, as the myGlobal variable is not a local of that function. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 54 TestComplete Made Easy To evaluate the myGlobal variable, go to the Watch List window and add a new item by rightclicking in the window. Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 55 The output in the Watch List window will allow you to monitor the value of that variable during the life of the execution session. You can also use the Evaluate command available from the debug menu item in the editor: Copyright © 2008 AutomatedQA Corp. - 1.0 Release 56 TestComplete Made Easy The Evaluate dialog displays the current value of the expression. Copyright © 2008 AutomatedQA Corp. - 1.0 Release TestComplete IDE Environment 57 4.4 Summary In this chapter: · You got a tour of the TestComplete environment. · Located the Menus, Toolbars, Workspace areas, Object Browser and Project explorer. · Gained a good understanding of the Object Browser. · Got familiar with the TestComplete Code Editor and all its features. · Gained the necessary knowledge for debugging in the TestComplete Editor. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Part V Projects and Suites Projects and Suites 59 5 5.1 Projects and Suites Objectives This section looks at the structure of a TestComplete project and the parts that make up the various testing functionality included in a project. In this section you'll learn about: · The difference between a Project and Project Suite · Understand the components of a Project · Learn to use the Project Wizard · Create a simple test 5.2 Project Anatomy In TestComplete a Project is a container of test scripts and other Project Items used by the tests that make up the project. A Project Suite is a container of projects providing a mechanism to logically group related projects. To create a new project select File | New | Project... and you will be presented with the Create New Project dialog: Copyright © 2008 AutomatedQA Corp. - 1.0 Release 60 TestComplete Made Easy The Create New Project dialog presents you with a number of pre-configured Project Templates that are geared towards specific types of testing. The templates are: · General Purpose Test Project - useful for a wide variety of test scenarios · Object Driven Testing - for working with custom data structures · Unit Testing - for running MSTest, NUnit, JUnit, DUnit or TestComplete unit tests · Distributed Testing - for managing test execution of projects on different computers · HTTP Load Testing - for load testing web server applications · [All Items] - template that includes all of TestComplete's available Project Items Once you click OK on the Create New Project dialog you will be presented with the New Project Wizard which allows you to further customize your New Project. For more details refer to the following section on the New Project Wizard. After creating a new project you can view all of its Project Items and sub items from the Project Explorer. The various parts of a project are as follows: · MyProjectSuite - A Project Suite · MyProject - A Project Copyright © 2008 AutomatedQA Corp. - 1.0 Release Projects and Suites 61 · Script - A Project Item · Unit1 - A Project Item Element Structure of Projects in TestComplete In TestComplete, Projects function as containers for different pieces of functionality related to testing and are organized on disk in a similar file/folder structure. In fact, removing a node from Project Explorer only removes it from the logical view presented by TestComplete and does not actually delete the item from disk which means you can easily add removed items back to a project. Here is the above project viewed from within Windows Explorer: Projects Projects can contain the following: · Project Items: Provide support for a specific type of testing. · Project Item Elements: The child nodes that represent testing functionality of the Project Item or serve to organize its contents. · Folders: Provides a means of organizing Project Items and Project Item Elements within a Project When a project is initially created you have the opportunity to specify which Project Items you want included. You can add and remove Project Items at any point. Adding them at the time a project is created is a matter of convenience. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 62 TestComplete Made Easy Both Project Suites and Projects provide a logical view of the files and folders that make up the project. When removing nodes from the Project Explorer you are only removing them from this logical view. The actual files and folders are not deleted from disk and may be added back to the project using the right-click context menu and selecting Add | Existing Item... Project Items Project Items make up the specific types of testing functionality or assist in performing various test operations. TestComplete includes a large collection of Project Items covering a wide variety of test functionality. You can easily add and remove Project Items using the right-click menu on the Project node of the Project Explorer. 5.3 New Project Wizard The New Project Wizard is provided as a convenience allowing you to configure a new project with a default set of testing functionality. It's not crucial to know up front all of the necessary Project Items that your project will require as Project Items can be added or removed directly from the Project Explorer after the project has been created. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Projects and Suites 63 Project Templates Initially, accepting the defaults on this dialog will be the preferred choice until your familiar enough with the available Project Items and can identify the ones you use most frequently at which point you can create a Project Template. To define a new template select the Project Items you use most frequently and click the Save As... button to create a new Project Template that will be available on the Create New Project dialog. Best Practice - Setting up a Custom Template If you're testing a Windows Application you may want to setup a Project Template that's geared towards that type of testing. Project templates are located in \Bin\ProjectTemplates.xml making it easy to share templates with your entire team. In any testing organization it's important to establish standards like this to help maintain consistency across your testing organization. The following walkthrough demonstrates how to create a custom Project Template you may find useful for testing Windows applications: 1. Select File | New | New Project... 2. On the Create New Project dialog from the list of Templates select the [All Items] template 3. Click the Unselect All button at the bottom of the Project Items checkbox 4. Check the following Project Items: - Name Mapping - Stores Copyright © 2008 AutomatedQA Corp. - 1.0 Release 64 TestComplete Made Easy - Win32 Tested Applications 5. In the left hand column on the dialog click Win32 Tested Applications 6. At the bottom of the Items list click the Add button to add a specific Windows application to test against 7. On the Create New Item dialog fill in the name of your application and click Next 8. In the Tested application edit box type the complete filename including path to the Windows application you wish to test or use the ellipsis (...) button to select the application 9. Click the Finish button 10. In the left hand column of the dialog click Select Project Items 11. Click the Save As... button 12. On the Save Template dialog enter a Template Name and Description and click OK to create a new project template that you can reuse 13. Click the Finish button Deleting a Project Template TestComplete 6.0 does not have built-in UI for editing or deleting Project Templates. However, you can manually edit \Bin\ProjectTemplates.xml using a plain text editor such as Windows Notepad to delete or modify an existing template. 5.4 Hands on Lab: Create a Simple Test Creating a Simple Test 1. Select File | New | New Project... Copyright © 2008 AutomatedQA Corp. - 1.0 Release Projects and Suites 65 2. Select General Purpose Test Project and click the OK button 3. On the New Project Wizard click the Finish button, accepting the defaults 5.5 Summary In this chapter we covered the structure of a TestComplete project and the parts that make up the various testing functionality included in a project. You should be familiar with how to construct a Project Template for use across your organization for greater consistency and easy of use when creating new test projects. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Part VI Project Items Project Items 67 6 6.1 Project Items Objectives This section provides an overview of all project item types with additional detail on the Win32 Tested Application. 6.2 Project Items The Project Wizard Select Project Items tab allows you to select which project items are included in the project. · ActiveX - This project item allows you to load an ActiveX object in TestComplete's memory space and use that object in your tests. For example you could use the Microsoft ADO Data Control to work with databases. · Events - This project item is used to hook to TestComplete events (and those of other application, such as ActiveX controls). This item is not required but is highly recommended. · HTTP Load Testing - Necessary for the creation of a load on a web server using TestComplete. · Low-Level Procedure Collection - A virtual folder for holding low-level (screen coordinate based tests) procedures. · Manual Test - A virtual folder for holding manual tests. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 68 TestComplete Made Easy · Name Mapping - Used to map the name of an object to a shorter name (aliasing). · Network Suite - Used in distributed testing. · ODT - Object Driven Testing used to add pseudo class structure to script code. · Script - Holds a collection of script units. THIS ITEM IS REQUIRED. · Stores - Holds collections of checkpoints used in a project · Unit Testing - A virtual folder for holding Unit Tests. · User Forms - A virtual folder for holding User Forms (Forms presented to the user during the test run, such a progress dialog, etc). · Web Services - A virtual folder for holding connection, methods and type of web services (Information from the WSDL file). · Win32 Tested Application - Holds information for managing the Application(s) under test. 6.2.1 Win32 Tested Applications The screenshot below the configuration of Win32 tested applications: · Icon - Show the icon associated with the tested application · Launch - If checked, this application will be run if TestedApps.RunAll command is used (either from script or context menu). · Name - Is the name that TestComplete uses to refer to the tested application (must be a name that the scripting language can handle). · File Name - Is the name of the application on the disk. · Count - This is the number of instances of the application that TestComplete will launch. If the application is already running TestComplete will post a warning message in the Test Log. · File Path - By default, File Path is the relative path to the file name from the TestComplete project. · Run Mode - How the application is launched. · Parameters - Allows parameters to be set using the ellipses button. Run Mode · Simple - Launches the application under the same user account as TestComplete. Parameters can be passed in Simple mode. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Project Items 69 · RunAs - Launches the application under the user account specified by the parameters dialog. · Debug - Launches the application under the same user account as TestComplete, then TestComplete attaches to the application as a "debugger". The stack trace of any exception that occurs in the application while the test(s) are being run will be recorded in the TestLog. This option requires debug information in the application under test. · Profile - Launches the application inside of AQTime using the profile (or AQTime project) specified in the parameters dialog. For example code coverage profiling could be used to see how much of the code is being tested by your automated tests. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 70 TestComplete Made Easy 6.3 Summary In this section we had a brief overview of the project items of TestComplete. We also looked at Win32 Tested Application project item in more detail. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Part VII Test Log 72 TestComplete Made Easy 7 7.1 Test Log Objective 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. In this section you will: · Learn about the basic Test (Results) Log. · How to view the Test Log in Internet Explorer. · How to reduce test log size using LockEvents. · Learn how to email the test log. 7.2 Script Log Logs are used to persist feedback from your tests including errors, warning messages and events as well as entire files and images. Logs are stored in a directory as XML files. Log Tree This area will have a node for each Test Item level used to run the test. In the image above, for example, a project suite was run. The project suite is the top (root) node and each project is represented by the child of the project suite. The statuses of child items in the tree bubble up to the parent items. In the screenshot above you can see that errors flagged in child level items (the red X indicates the error status) have bubbled up to the project suite node. The context menu for the Log Tree contains menu items to handle the log output including Export to IE, Send Email and the ability to view closed Log Panels. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Test Log 73 Script Log This area contains messages coming from both TestComplete and the script code. The are six different types of messages: · Message - Can come from TestComplete or from the script code (Log.Message), will not cause the test to fail. · Warning - Can come from TestComplete or from the script code (Log.Warning), not necessary a failure for the test but could be an indicator for why a test failed. · Error - Can come from TestComplete or from the script code (Log.Error), this indicates a failure for the test. · Events - Usually comes from TestComplete but can come from the script as well (Log.Event), does not cause the test to fail. TestComplete generates an event for every mouse-click or keyboard entry in the test. · Image - Usually comes from script code (Log.Picture) but TestComplete can generate as well (Region Checkpoints). · File - There are two types of File log items. Log.File, will copy the file into the directory holding the log XML file and creates a hyperlink to the file. Log.Link just creates a hyperlink to the file without copying the file. The script log area may have a hierarchical structure via creating and pushing log folders onto the log ( Log.AppendFolder, Log.CreateFolder/Log.PushLogFolder, Log.PopLogFolder). All messages by default go into the last pushed log folder (i.e., the top of the stack). 7.3 Emailing Result Sending the result via email can be done either by script code (see help file for examples) or after the test run by selecting Send via Email... from the Log Tree context menu. Selecting Send via Email... creates an email with a multi-part hypertext file attachment. To preview what this file will look like, select View Results in IE from the context menu. View Results in IE also shows how TestExecute will display Test Results after a test run. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 74 TestComplete Made Easy 7.4 LockEvents With any long running test, the test result log will be filled with hundreds if not thousands of events. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Test Log 75 Most of the time, the tester is not interested in events unless there is a problem in the test run. TestComplete can eliminate events unless an error occurs. By adding Log.LockEvents to the script code, no events will be placed into the test log unless an error occurs. By default the last 20 events are logged, but this can be changed by adding a parameter to the Log.LockEvents command. 7.5 Summary In this section we learned about the test log and the different type of messages available in TestComplete. We learned how to email the test log and also how to reduce the size of the test log. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Part VIII Named Mappings Named Mappings 77 8 8.1 Named Mappings Objectives This section introduces Named Mappings and Aliases used to handle long object identifiers and to provide identifiers with meaningful names. In this section you will learn about: · Named Mapping. · Aliases and how they are different from Name Mapping · How TestComplete uses Alias and Name Mapping. 8.2 Map to Object TestComplete provides Named Mappings and Aliases to tame extremely long object identifiers that have meaningless default names. For example: Sys.Process("Hello").Panel1.Panel2.Container1.Container2.button1 Clearly there are numerous issues with this identifier, its long and awkward not to mention we have no clue about the purpose or identity of "Container1", "Container2" or "button1". Named Mappings allow you to rename Panel1, Panel2, Container1, Container2 and button1 to useful names like MyPanel, myInsidePanel, myTabs, myPages and btnSubmit. The issue here is that you still need to type: NameMappings.Sys.Process("Hello").MyPanel.myInsidePanel.myTabs.myPages.btnSubmit TestComplete lets you create an Alias to represent this long string. If you create the Alias "btnSubmit", you only need to type: Aliases.btnSubmit Consider the AutomatedQA website Products link at the top of the page: The standard full name for this HTML element is: Sys.Process("iexplore").Page("http://www. automatedqa.com/").Panel(0).Panel(0).Link(1). This does not tell anyone reading the script what HTML element the code is working with. There are a Copyright © 2008 AutomatedQA Corp. - 1.0 Release 78 TestComplete Made Easy couple of ways to map an on-screen object in TestComplete: · Select the element in the Object Browser or Object Properties Window, and right-click for the context menu and select "Map the Object Name..." · Use the Map Object from Screen ( ) button from the Tools toolbar. 1. Click the Map Object from Screen button to displays the Map Object dialog. 2. Use the finder tool ( ) to select the Products link and push the OK button. 3. If the NameMapping project item is not in the project, TestComplete will ask if you want to add the NameMapping project item. 4. Click the Yes button. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Named Mappings 79 5. Click the OK button. 6. If the parent objects have not already been mapped, TestComplete will require them to be mapped before mapping the selected item. 7. Click the Yes button. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 80 TestComplete Made Easy 8. The Object Name Mapping dialog will be shown. · In the caption of the Object Name Mapping dialog, there is an indicator that shows how many items need to be mapped in order to map the selected item. · The standard TestComplete name for the object is shown just below the caption. · The Selected Properties is used by TestComplete to find the on-screen object. · The properties that are selected for a given on-screen object are configured using the Templates button. · Any property that is listed in Selected Properties or Available Properties can be added or removed. · The OK button will add the object to the NameMapping project item and the Aliases part of the NameMapping project item. · The Skip button will add the object to the Mapped Object part but not into the Aliases part of the NameMapping project item. 9. Aliases are best explained by example, we are going press the Skip button for both the Sys object... Copyright © 2008 AutomatedQA Corp. - 1.0 Release Named Mappings 81 10.And the Skip button for the Process object. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 82 TestComplete Made Easy 11.Rename the Page Object to "HomePage" and click the OK button. 12.Press the Skip button for the Panel Objects (Skip two times). Copyright © 2008 AutomatedQA Corp. - 1.0 Release Named Mappings 83 13.On the second Panel object, TestComplete will say the it does not have enough information to make this panel unique in the NameMapping project Item. Although, TestComplete can work with non-unique objects, it is more reliable to have the object be unique. 14.Press the No button. 15.Find the Parent property in the Available Properties and click the ellipse button. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 84 TestComplete Made Easy 16.Select the Parent.Name property and add it to the Selected Properties. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Named Mappings 85 17.Press the Skip button. 18.Since there is the possibility that a new link could be added before the Products link, the Selected Properties will be changed from the standard properties. First, remove the Name property from Selected Properties, then add the innerText property. Change the Mapped Name to "ProductLink" and Press the OK button. 19.The NameMapping project item editor with all nodes expanded now looks like: Copyright © 2008 AutomatedQA Corp. - 1.0 Release 86 TestComplete Made Easy In script code, the Product link can be referred to by the following code: Sys.Process("iexplore").Page("http://www.automatedqa.com/").Panel(0).Panel(0).Link(1) or NameMapping.Sys.iexplore1.HomePage.Panel_0_.Panel_0_.ProductLink or Aliases.HomePage.ProductLink In this way, Aliases allow you to ignore on-screen objects that were used for design but are not necessary to the test automation process. 8.3 Highlight Objects During mapping or after the fact, objects being referred to can be highlighted on the screen. In the Name Mapping dialog, this is done by pressing the Highlight button. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Named Mappings 87 In the NameMapping project item editor, highlighting is done by selecting Highlight on Screen from the context menu (right-clicking). Copyright © 2008 AutomatedQA Corp. - 1.0 Release 88 TestComplete Made Easy 8.4 Mapping Dialog The parts of the Mapping dialog are listed below: · Mapped Name - lets you define the name for an on screen object · Description - short note about the object · Selected Properties - the properties that are used to define this on screen object for name mapping. · Available Properties - additional properties that can be use to help refine the name mapping. · Template Name - which template that TestComplete used to define the Selected Properties initially. · Select - if the on screen object matches one than one possible template, this button allows you to choose which template to use. · Templates - Allows you to add/edit Templates. · Highlight - Highlights the currently selected object on the screen if possible. · OK - Add the selected object to both the Mapped Objects and the Aliases sections of the NameMapping project item. · Skip - Add the selected object to the Mapped Objects only. · Cancel - Cancel the mapping at this point (all items mapped before will still be mapped). Copyright © 2008 AutomatedQA Corp. - 1.0 Release Named Mappings 89 · Help - Brings up the help on this dialog. 8.5 Aliases in Scripts If you are recording a script and have the NameMapping project item in the current project, TestComplete will first try to use the Aliases project item in the recording. If that does not work, it will use the NameMapping project item. In manual coding you can use the Aliases as well. If the Alias object is available in the Object Browser, then TestComplete will present all the properties and methods for that object. If the object is not available in the Object Browser, TestComplete will present a smaller subset of methods and properties. This can be changed in the Options dialog (Tools | Options| Engines | Name Mapping) by selecting the Store CodeCompletion Information. This does increase the size of the NameMapping project item file but allows you to code without having the tested application open. 8.6 Summary We learned about what name mapping is and what it is used for. The difference between Aliases and Name Mapping was explained. And we learned how to map an object from the screen. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Part IX Unit Testing Unit Testing 91 9 9.1 Unit Testing Objectives This section discusses unit testing, the types of unit test frameworks supported by TestComplete and provides an example of using an NUnit unit test. In this section you will: · Learn about the types of unit test framework supported by TestComplete · See an example of using a Unit Test. 9.2 Supported Unit Testing Types Running unit tests within TestComplete has several advantages: · Management gets a single report that includes both unit and automated tests. · Provides an easy way for Quality Assurance to run unit tests (in addition to Developers running unit tests). · Can make it possible to run unit tests as part of the build process. TestComplete supports five different types of Unit Testing: · DUnit - A unit test framework for Delphi Applications, require that the test application be compiled as open and include the tcDUnitSupport.pas file. · JUnit - A de-facto standard unit test framework for Java Applications. · MSTest - A unit test framework designed by Microsoft for unit testing .NET applications, comes with Visual Studio 2008 and Visual Studio 2005 Team Edition. · NUnit - An open-source unit test framework based on JUnit, used for unit testing .NET applications. · TCUnitTest - A unit test frame work that allows unit testing of any open application. Some of the unit test frameworks require that TestComplete know where the test runner application is located on the test machine. The information can be entered in the Options Dialog (Tool | Options from the main menu). From the Options Dialog select Engines | Unit Testing. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 92 TestComplete Made Easy 9.3 NUnit Example NUnit is a popular .NET unit testing framework (available at http://www.nunit.org). When it is installed, it includes a sample unit test assembly. 1. Add a Unit Testing Project Item to your project. 2. Add a NUnit Project Item under the Unit Testing Project Item. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Unit Testing 93 3. Click the ellipses button for the Assembly file name. Add the Assembly that holds the NUnit tests. 4. Push the OK button. This will open the NUnit editor in TestComplete. 5. Right-Click the NUnit1 Project Item and run the test. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 94 TestComplete Made Easy The screenshots below show sample output and logging for the test run. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Unit Testing 95 9.4 Hands on Lab: Running a Unit Test 1. Create a new project 2. Add the "TestedApps" Project Item. 3. Add the "UnitTestingDemo" application to the project from the directory " \Samples\Unit Testing\C#\bin\" 4. Run the Application (Right-Click on the "UnitTestingDemo" Project Item). 5. Add a "Unit Testing" Project Item 6. Add a "TCUnitTest" Project Item to the "Unit Testing" Project Item. 7. Click the ellispe button (...) next to the process. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 96 TestComplete Made Easy 8. Select the "UnitTestingDemo" Process. 9. Select the Mode of "Run selected tests only". 10.Click the Load button. 11.Uncheck the "ShowNum" Method (this method has a UI which we do not want to handle in a unit test). 12.Click Run on the "TCUnitTest1" Project Item. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Unit Testing 97 Most of the work for Test Cases in the Unit Test is done by the developer in the Application. 9.5 Summary We learned about the types of unit test frameworks supported by TestComplete and how to use an NUnit unit test. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Part X Manual Testing Manual Testing 99 10 10.1 Manual Testing Objectives 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. In this section you'll learn: · What a Manual Test is · How to setup a Manual Test Project · How to create a Manual Test · How to use script within a Manual Test 10.2 Setting up a Manual Test Project A Manual Test in TestComplete is a test that is performed by an individual who is directed by instructions presented on screen. TestComplete Manual Tests allow the person performing the test to indicate whether or not the test passed or failed and provide additional feedback in the event of a failure. Creating a New Manual Test There is no default template for creating a Manual Test so we'll walk through setting up a new project for Manual Testing: 1. From the main menu select File | New | New Project... which will display the Create New Project dialog 2. Select General Purpose Test Project and click OK 3. On the Project Wizard dialog click the Unselect All button then under Project Items check Manual Test and Win32 Tested Applications items Copyright © 2008 AutomatedQA Corp. - 1.0 Release 100 TestComplete Made Easy You now have a test that's setup for Manual Testing. 10.3 Hands on Lab: Create a Manual Test The step-by-step walk-through below demonstrates how to create a manual testing project, set up a manual test, add steps to the manual test and how to run the manual test. Creating a Manual Testing Project 1. Create a Project in TestComplete (with a new Project Suite) Copyright © 2008 AutomatedQA Corp. - 1.0 Release Manual Testing 101 2. Select General-Purpose Test Project Template and click OK 3. On the Project Wizard dialog click Unselect All and then check Manual Test and Win32 Tested Application Copyright © 2008 AutomatedQA Corp. - 1.0 Release 102 TestComplete Made Easy 4. Click Finish Setting up a Manual Test Here we'll walk through setting up a Manual Test using a sample application provided with TestComplete called Orders.exe. 1. Right click on TestedApps and select Add | New Item... 2. Select Orders.exe (which is a sample application included with TestComplete) 3. Double click on ManualTest1 to open the editor in the Workspace Copyright © 2008 AutomatedQA Corp. - 1.0 Release Manual Testing 103 4. Change Test caption to "Manual Test" and Test description to "Hands on Lab" 5. Under Test instructions type "Orders application must be running to complete this test" 6. Under Test Steps right-click and select Preview Step Dialog... (click Yes on the prompt to save the dialog) Copyright © 2008 AutomatedQA Corp. - 1.0 Release 104 TestComplete Made Easy 7. Click Cancel to close the dialog Adding Steps to a Manual Test 1. Under Test Steps click the Add Step 2. In the Step caption edit box type "open" 3. Add the directions for opening a table to the Step Instructions button Copyright © 2008 AutomatedQA Corp. - 1.0 Release Manual Testing 105 4. Add another step using the Add Step Quantity" button and set the caption to "Add Order and Verify 5. Enter the following Step Instructions: a. Select Order | New Order... from the main menu b. Enter 2 in the Quantity Field c. Verify that the Total Field equals 200 Copyright © 2008 AutomatedQA Corp. - 1.0 Release 106 TestComplete Made Easy Running a Manual Test In this section we'll walk through running a manual test and logging mock failures along the way. 1. In the Project Explorer right click ManualTest1 and select Run ManualTest1 2. Click Begin Test 3. Click Fail 4. Enter "Unable to find table" in the comment field 5. Click Try Again 6. Follow the reset of the step's instructions 7. Click Success 8. Click Fail on the next step 9. Click Continue At this point, you should see the following test log: Copyright © 2008 AutomatedQA Corp. - 1.0 Release Manual Testing 107 10.4 Hands on Lab: Scripting and Manual Testing In this section we'll illustrate using Scripts with manual tests and cover how to hook Manual test events. Using Manual Tests from Script Code 1. Create a new TestComplete project. 2. Double click Unit1 under the Scripts node in the Project Explorer to open the code editor. VBScript is used in this example and your code may vary if you're using another scripting language. 3. In the Main routine, add a blank line under the "Enter Code Here" comment 4. Press Ctrl-Space to display the Code Completion window 5. Select TestedApps from the list. Note: Once the list appears you can begin typing to select the item from the list. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 108 TestComplete Made Easy 6. With the cursor at the end of TestedApps type a period "." to invoke the Code Complete again and select Orders 7. Type another period and select Run 8. Press Return to add a new blank line below TestedApps.Orders.Run() 9. Press Ctrl-Space to display the Code Completion window 10.Select ManualTest1 11. Type "." and select Start 12. Press Return to add a new line below ManualTest1.Start 13. Press Ctrl-Space to display the Code Completion window 14. Select TestedApps 15. Type a period "." and select TerminateAll Copyright © 2008 AutomatedQA Corp. - 1.0 Release Manual Testing 109 Script Interactions with Manual Tests In this example, we'll illustrate using Events and Script to interact with a user during a Manual Test. This example will build upon the Manual Test created in the previous step. 1. With the previous project still open expand the Events node in the Project Explorer 2. Double click the GeneralEvents node 3. In the Workspace under Available Events expand the Manual Testing Events node Copyright © 2008 AutomatedQA Corp. - 1.0 Release 110 TestComplete Made Easy 4. Double click the OnBeforeStep event to add the event to your test 5. Under Events to Handle scroll the list down and locate the Manual Testing Events node 6. Click on the OnBeforeStep item then click the New button 7. Click OK on the New Routine dialog to add a new function to the Unit1 test script 8. In your Unit1 script file add a new blank like below the function declaration and type 'BuiltIn. ShowMessage("Hi from script")' 9. Run the Project and click the Begin Test button. Notice the ShowMessage dialog appears: Copyright © 2008 AutomatedQA Corp. - 1.0 Release Manual Testing 111 10.5 Summary In this section, we learned about TestComplete's Manual Testing features and constructed a simple manual test using one of the provided sample applications. We also illustrated how you can interact with manual tests from scripts. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Part XI Basic Record and Playback Basic Record and Playback 113 11 11.1 Basic Record and Playback Objectives This section demonstrates how to perform basic record and playback tasks including: · Understanding the recording toolbar. · How to starting a recording. · How to use buttons on the Recording Toolbar. · Perform a basic recording. 11.2 Overview TestComplete has rich Record/Playback functionality allowing you to quickly record new test scripts. TestComplete has several options that allow you to control how recording is performed. To view/change these options select Tools | Options... and click the Engines folder and select Recording. You should see the following options: Copyright © 2008 AutomatedQA Corp. - 1.0 Release 114 TestComplete Made Easy 11.3 Recording Toolbar Anatomy TestComplete Recording Toolbar The TestComplete recording toolbar looks like this: The buttons are as follows: Capture Screen Copyright © 2008 AutomatedQA Corp. - 1.0 Release Basic Record and Playback 115 Add Text to Script Run Tested Application Add Checkpoint From the List Start Recording Stop Recording Pause Recording Record Low Level Procedure (screen coordinates) Record Low Level Procedure (window coordinates) Record Script Record an HTTP Task More Details Clicking the More Details button will expand the toolbar such that it displays Parent and Object name data for the item underneath the mouse cursor. Starting a Recording To start a recording you must have a project loaded. You can load an existing project or start a new project. Once you have a project loaded there are two ways to begin a new recording: 1. Selecting Script | Record from the TestComplete main menu 2. Press the Record toolbar button on the Test Engine toolbar: 11.3.1 Adding Text The Add Text to Script toolbar button allows you to insert either script or comments into the routine that's currently being recorded. Clicking this button displays the Add Text to Script dialog: Copyright © 2008 AutomatedQA Corp. - 1.0 Release 116 TestComplete Made Easy Notice there is a checkbox at the bottom that allows you to indicate that the text is to be inserted as a comment. There is also a Pick Object... button that allows you to insert a line of code that references a specific onscreen object. 11.3.2 Changing Recording Types The recording toolbar has several buttons (see circled buttons below) that allow you to control the type of recording being performed. The different recording types are: Record Low Level Procedure based on screen coordinates Record Low Level Procedure based on window coordinates Record a Script (default) Record an HTTP task To switch the type of recording simply click the appropriate button. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Basic Record and Playback 117 11.3.3 Pausing TestComplete allows you to pause in the middle of a recording by clicking on the Pause button. Pausing a test allows you to manipulate the application under test or change the environment without recording any of those actions into the script. To resume a paused test click the Start Recording button. 11.3.4 Stopping To stop a recording click the Stop button. Clicking the Stop button will close the Recording toolbar and restore the TestComplete main window leaving you in the Code Editor on the newly recorded script. 11.4 Hands on Lab: Perform a Basic Recording Recording a basic script 1. Create a new project and project suite using the General Purpose Test Project template: Copyright © 2008 AutomatedQA Corp. - 1.0 Release 118 TestComplete Made Easy 2. Click the Record button on the toolbar 3. Click the Windows Start button 4. Select Run... 5. Type "notepad.exe" and click the OK button 6. Once Windows Notepad starts type "this is a test from TestComplete" 7. Click the Stop button on the recording toolbar to end the recording 11.5 Summary In this section you learned how to perform basic record and playback tasks. We discussed the functionality available on the toolbar including how to record various types of activity. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Part XII Low Level Procedure 120 TestComplete Made Easy 12 12.1 Low Level Procedure Objectives In this section you will: · Get a clear understanding of when to use Low Level Procedure · Understand the choices for Low Level Procedure during recording · Understand the editing screen of Low Level Procedure after the recording session · How to play back a Low Level Procedure session successfully 12.2 Recording The reason you want to use the Low Level Procedure feature in TestComplete is when the need arises for recording specific mouse or keyboard operations on the screen for playback that are not automatically recorded during a regular recording session. For example, if TestComplete would record every mouse and keyboard operation automatically during each recording session, we would have ended up with thousands of lines of script identifying the mouse movement coordinates and clicks, while in most cases these are not necessary. On the other hand, if you are trying to Paint in a program like MS Paint or trigger a Hover event inside of Internet Explorer or FireFox, it is very much necessary that the recorder brings in the valuable mouse and keyboard coordinates, clicks and keystrokes. 1. Start a new project normally in TestComplete as shown in the figure below: Copyright © 2008 AutomatedQA Corp. - 1.0 Release Low Level Procedure 121 2. Make sure to enable Low Level Procedure Collection in the Project Wizard. If you forget, no worries. You will still be able to add it to the project after the fact using the Add New Item menu of the project in the Project Explorer. Copyright © 2008 AutomatedQA Corp. - 1.0 Release 122 TestComplete Made Easy 3. When you start a recording session in TestComplete, you are presented with the recording tool bar shown below. On the recording tool bar are two buttons that enable Low Level Procedure recording: · The Screen Coordinates based button, which automatically set the coordinates for the recording as (0,0) to be the top most left of the screen. · The Window Coordinates based button, which sets the (0,0) coordinates starting from top most left window under recording. Tip: For a smoother playback and easier implementation between different resolutions on the screen, we recommend the "Window Coordinates" button to be used. Copyright © 2008 AutomatedQA Corp. - 1.0 Release Low Level Procedure 123 12.3 Hands on Lab: MS Paint Test In this Lab, we will Low Level Procedure record MS Paint to sign a name on the screen. 1. Start a new Project 2. Enable Low Level Procedure Collection in the Wizard. 3. Start MS Paint in the Windows Directory or System32 directory depending on your version of Windows. 4. Start recording 5. Choose the Low Level Procedure - window coordinates button from the recording toolbar. 6. Drag the button from step 5 above to the MS Paint main window of the application until you see a red line around the entire MS Paint window. 7. The Create Project item dialog below will appear. Name your colle