Effective GUI Test Automation: Developing an Automated GUI Testing Tool

pdf
Số trang Effective GUI Test Automation: Developing an Automated GUI Testing Tool 415 Cỡ tệp Effective GUI Test Automation: Developing an Automated GUI Testing Tool 9 MB Lượt tải Effective GUI Test Automation: Developing an Automated GUI Testing Tool 0 Lượt đọc Effective GUI Test Automation: Developing an Automated GUI Testing Tool 2
Đánh giá Effective GUI Test Automation: Developing an Automated GUI Testing Tool
4.2 ( 15 lượt)
Nhấn vào bên dưới để tải tài liệu
Đang xem trước 10 trên tổng 415 trang, để tải xuống xem đầy đủ hãy nhấn vào bên trên
Chủ đề liên quan

Nội dung

Effective GUI Test Automation: Developing an Automated GUI Testing Tool Kanglin Li Mengqi Wu SYBEX® Effective GUI Test Automation: Developing an Automated GUI Testing Tool Kanglin Li and Mengqi Wu San Francisco • London Associate Publisher: Joel Fugazzotto Acquisitions and Developmental Editor: Tom Cirtin Production Editor: Erica Yee Technical Editor: Acey J. Bunch Copyeditor: Judy Flynn Compositor: Laurie Stewart, Happenstance Type-O-Rama Graphic Illustrator: Jeff Wilson, Happenstance Type-O-Rama Proofreaders: Laurie O’Connell, Amy Rassmussen, Nancy Riddiough Indexer: Ted Laux Cover Designer: Ingalls + Associates Cover Illustrator/Photographer: Rob Atkins, Image Bank Copyright © 2005 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501. World rights reserved. The author(s) created reusable code in this publication expressly for reuse by readers. Sybex grants readers limited permission to reuse the code found in this publication or its accompanying CD-ROM so long as the author(s) are attributed in any application containing the reusable code and the code itself is never distributed, posted online by electronic transmission, sold, or commercially exploited as a stand-alone product. Aside from this specific exception concerning reusable code, no part of this publication may be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic, or other record, without the prior agreement and written permission of the publisher. Library of Congress Card Number: 2004108202 ISBN: 0-7821-4351-2 SYBEX and the SYBEX logo are either registered trademarks or trademarks of SYBEX Inc. in the United States and/or other countries. TRADEMARKS: SYBEX has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer. The author and publisher have made their best efforts to prepare this book, and the content is based upon final release software whenever possible. Portions of the manuscript may be based upon pre-release versions supplied by software manufacturer(s). The author and the publisher make no representation or warranties of any kind with regard to the completeness or accuracy of the contents herein and accept no liability of any kind including but not limited to performance, merchantability, fitness for any particular purpose, or any losses or damages of any kind caused or alleged to be caused directly or indirectly from this book. Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 SOFTWARE LICENSE AGREEMENT: TERMS AND CONDITIONS The media and/or any online materials accompanying this book that are available now or in the future contain programs and/or text files (the “Software”) to be used in connection with the book. SYBEX hereby grants to you a license to use the Software, subject to the terms that follow. Your purchase, acceptance, or use of the Software will constitute your acceptance of such terms. The Software compilation is the property of SYBEX unless otherwise indicated and is protected by copyright to SYBEX or other copyright owner(s) as indicated in the media files (the “Owner(s)”). You are hereby granted a single-user license to use the Software for your personal, noncommercial use only. You may not reproduce, sell, distribute, publish, circulate, or commercially exploit the Software, or any portion thereof, without the written consent of SYBEX and the specific copyright owner(s) of any component software included on this media. In the event that the Software or components include specific license requirements or end-user agreements, statements of condition, disclaimers, limitations or warranties (“End-User License”), those End-User Licenses supersede the terms and conditions herein as to that particular Software component. Your purchase, acceptance, or use of the Software will constitute your acceptance of such End-User Licenses. By purchase, use or acceptance of the Software you further agree to comply with all export laws and regulations of the United States as such laws and regulations may exist from time to time. Reusable Code in This Book The author(s) created reusable code in this publication expressly for reuse by readers. Sybex grants readers limited permission to reuse the code found in this publication, its accompanying CD-ROM or available for download from our website so long as the author(s) are attributed in any application containing the reusable code and the code itself is never distributed, posted online by electronic transmission, sold, or commercially exploited as a stand-alone product. Warranty SYBEX warrants the enclosed media to be free of physical defects for a period of ninety (90) days after purchase. The Software is not available from SYBEX in any other form or media than that enclosed herein or posted to www.sybex.com. If you discover a defect in the media during this warranty period, you may obtain a replacement of identical format at no charge by sending the defective media, postage prepaid, with proof of purchase to: SYBEX Inc. Product Support Department 1151 Marina Village Parkway Alameda, CA 94501 Web: http://www.sybex.com After the 90-day period, you can obtain replacement media of identical format by sending us the defective disk, proof of purchase, and a check or money order for $10, payable to SYBEX. Disclaimer SYBEX makes no warranty or representation, either expressed or implied, with respect to the Software or its contents, quality, performance, merchantability, or fitness for a particular purpose. In no event will SYBEX, its distributors, or dealers be liable to you or any other party for direct, indirect, special, incidental, consequential, or other damages arising out of the use of or inability to use the Software or its contents even if advised of the possibility of such damage. In the event that the Software includes an online update feature, SYBEX further disclaims any obligation to provide this feature for any specific duration other than the initial posting. The exclusion of implied warranties is not permitted by some states. Therefore, the above exclusion may not apply to you. This warranty provides you with specific legal rights; there may be other rights that you may have that vary from state to state. The pricing of the book with the Software by SYBEX reflects the allocation of risk and limitations on liability contained in this agreement of Terms and Conditions. Shareware Distribution Software Support Components of the supplemental Software and any offers associated with them may be supported by the specific Owner(s) of that material, but they are not supported by SYBEX. Information regarding any available support may be obtained from the Owner(s) using the information provided in the appropriate read.me files or listed elsewhere on the media. Should the manufacturer(s) or other Owner(s) cease to offer support or decline to honor any offer, SYBEX bears no responsibility. This notice concerning support for the Software is provided for your information only. SYBEX is not the agent or principal of the Owner(s), and SYBEX is in no way responsible for providing any support for the Software, nor is it liable or responsible for any support provided, or not provided, by the Owner(s). This Software may contain various programs that are distributed as shareware. Copyright laws apply to both shareware and ordinary commercial software, and the copyright Owner(s) retains all rights. If you try a shareware program and continue using it, you are expected to register it. Individual programs differ on details of trial periods, registration, and payment. Please observe the requirements stated in appropriate files. Copy Protection The Software in whole or in part may or may not be copy-protected or encrypted. However, in all cases, reselling or redistributing these files without authorization is expressly forbidden except as specifically provided for by the Owner(s) therein. To Li Xuanhua and Tang Xunwei And In memory of Luo Youai, Luo Xulin, and Li Congyang Acknowledgments o the folks at Sybex, especially Tom Cirtin who made this book available, Acey J. Bunch for his technical expertise, and Erica Yee and Judy Flynn for their contributions to this book. I want to thank Rodnay Zaks, the president of Sybex, who signed the contract. I also extend my thanks to the other people in the Sybex team. I still need to thank other people, especially the readers who have provided me with their comments and suggestions about my previous works. During the process of writing this book, the test monkey in Chapter 3 frequently reminded me of my early days as a schoolboy. My friends and I spent most of my childhood summer nights listening to the stories of the monkey king told by the old folks in our village. What I learned from both the old folks and my friends makes it possible for me to write this book today. When I was a small boy, my uncle OuYang Minghong carried me in a bamboo basket to visit my grandma. My uncles Zuomei and Zuodian carried me on their backs or in a wheelbarrow to watch movies and catch fish. Since I was five, my aunt Youai led me to the school and taught me to count with my fingers. I didn’t learn how to swim and fell into a pool when I was eight or nine. Meiqing risked his life and saved me from the water with the help of my uncle Zuohuang, Guicheng, and another whose name I don’t know. Meiqing has always been my big brother. Then I learned how to swim at 20 and swam across the Xiangjiang River on a summer day and the Leishui River on a cold fall afternoon. Thank you all for teaching me about water, including Zeng Xilong, Li Wenbing, Kuang Chuanglun, Bai Maoye, Chen Xiaohu, Zeng Yigui, He Hechu, Wen Xiaoping, Long Yongcheng, and Xie Hengbing. Tang Duzhang, Li Zuojin, Li Zuojun, Luo Xixing, Chen Xinhua, and Kuang Chuangren and I spent our best years in the middle school. At that time we learned food was valuable. Together, we discovered that boys were shy and girls were caring. Thanks to all of the former classmates who form the memory of my childhood. —Kanglin Li Leiyang, China 2004 T Contents at a Glance Introduction xiv Chapter 1: GUI Testing: An Overview Chapter 2: Available GUI Testing Tools vs. the Proposed Tool 19 Chapter 3: C# Win32 API Programming and Test Monkeys 37 Chapter 4: Developing a GUI Test Library 99 Chapter 5: .NET Programming and GUI Testing 137 Chapter 6: Testing a Windows Form in General 175 Chapter 7: Architecture and Implementation of the Automatic GUI Test Tool 209 Chapter 8: Methods of GUI Test Verification 269 Chapter 9: Testing Label and Cosmetic GUI Controls 319 Chapter 10: Testing a TextBox Control with Input from a Keyboard 333 Chapter 11: Testing RadioButton and CheckBox Controls 353 Chapter 12: Menu Clicking for GUI Test Automation 367 Chapter 13: User-Defined and COM-Based Controls 389 Chapter 14: Testing Issues for Non .NET Applications 411 1 Selected Bibliography 429 Index 431 Contents Introduction Chapter 1 Chapter 2 GUI Testing: An Overview xiv 1 Unique Features of GUI Testing Developing an Automated GUI Testing Tool Expectation of Automated Testing Automated Test Teams How to Automate GUI Testing GUI Testing and Script Languages Using C# for Automation Test Scripts Summary 4 5 6 8 10 12 14 16 17 Available GUI Testing Tools vs. the Proposed Tool 19 Current GUI Testing Infrastructures Capture/Playback Is Not Automatic Test Monkeys Intelligent Automation Automatic GUI Testing Tools in the Marketplace CompuWare TestPartner IBM Rational Test Tools Mercury Interactive Tools Segue’s SilkTest Open Source GUI Test Tools Advantages and Disadvantages of the Commercial Testing Tools Computer-Assisted GUI Testing The Common Features of Capture/Playback Editing the Recorded Test Script Implementing Testability Hooks Reusability for Regression Testing 20 20 22 24 24 25 25 26 27 27 28 28 29 30 30 31 viii Contents Chapter 3 Chapter 4 The Proposed GUI Testing Approach Active GUI Test Approach Generating Testing Data First Data-Driven Test Scripts Summary 31 31 32 33 34 C# Win32 API Programming and Test Monkeys 37 Understanding the Custom DLLs C# API Programming PInvoke Basics The Marshal Class and the DllImport Attribute Data Type Presentation A Simple C# API Example C# API Text Viewer A Base Class An API Utility Class ConstantViewer Class DllImportViewer Class StructViewer Class GUI of the C# API Text Viewer Starting with a Test Monkey A Dumb Test Monkey A Smarter Monkey Summary 38 40 40 41 42 43 48 49 53 57 60 68 75 85 85 92 97 Developing a GUI Test Library 99 GUI Test and the Custom User32.dll Exploring the User32.dll Dumpbin.exe Dependency Walker Building a Dynamic Linking Library for GUI Testing The Spy++ Tool Functions from the User32.dll for GUI Testing Expanding the Testing Capabilities A GUI Test Application Summary 100 102 102 104 105 106 107 118 131 135 Contents Chapter 5 Chapter 6 ix .NET Programming and GUI Testing 137 XML Programming Writing XML Files Reading XML Files XPathNavigator Class XmlDocument Class Object Serialization Binary Serialization SOAP Serialization XML Serialization .NET System.Collections Namespace Type Class .NET System.Reflection Namespace Late Binding .NET System.Threading Namespace Summary 138 139 142 144 146 150 150 156 159 161 162 164 167 170 173 Testing a Windows Form in General 175 Overview of Software Architecture Presentation Layer Business Layer Data Layer GUI Components on the Presentation Layer Buttons ComboBoxes DialogBoxes Labels Menus TextBoxes Other Controls Expanding the GUI Test Library Methods for XML Accessibility and XML Serialization Methods for Late Binding Two Helper Classes Building a General Basis of a GUI Test Script Starting the Test Script Project 176 179 179 180 180 180 181 182 182 183 184 184 185 187 189 191 193 193
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.