1. 程式人生 > >《TestComplete Made Easy》讀書筆記

《TestComplete Made Easy》讀書筆記

TestComplete Made Easy 》下載:

TestComplete Made Easy 》讀書筆記( 1 -TestComplete 簡介

TestComplete 是這幾年測試工具領域異軍突起的一款自動化測試工具,由 AutomatedQA 出品,這幾年迅速發展,並且屢獲大獎,例如最近就獲得 Jolt 08 年度測試工具 Productivity 獎。

TestComplete 的最大特點是支援 VBScript DelphiScript JScript C#Script

C++Script 多種指令碼語言,可以讓測試人員選擇自己熟悉的指令碼語言進行自動化指令碼的編寫。

另外, TC 支援 .NET Delphi Java 等流行語言和平臺下的軟體的自動化功能測試,支援 WEB 功能和效能測試,支援分散式測試、單元測試等多種測試方式。

QTP Robot 等主流大牌廠商的自動化測試工具相比, TC 的優勢除了上面所說的,還有價格也是其主要競爭優勢之一。

國內目前對 TC 的關注和使用人數都不是很多,《軟體測試技術大全》這本書中有部分章節介紹了 TestComplete

工具的使用。

目前能找到的關於 TC 的書就僅有《 TestComplete Made Easy 》這本了。為此,特闢此專欄,通過研習《 TestComplete Made Easy 》來達到掌握 TC 的目的。

TestComplete Made Easy 》讀書筆記( 2 -TestComplete 安裝

TC 安裝的要求:

1 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.

2 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

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

TestComplete Made Easy 》讀書筆記( 3 -TestComplete 支援的測試型別

3.3 節中列舉了 TC 支援的各種測試型別,包括:

1 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.

2 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.

3 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.

4 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.

5 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.

6 HTTP Performance Testing HTTP 效能測試)

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.

TC 是目前市面上少有的以低廉的價格在一個工具內提供對多種型別測試支援的工具。

TestComplete Made Easy 》讀書筆記( 4 - 冒煙測試

冒煙測試是自動化測試中最重要,也最應該實現的測試。

The smoke test is crucial because of the time savings it can provide both R&D and QA.

冒煙測試能為開發和 QA 節省大量的時間,一個好的冒煙測試應該:

· 快速執行 - a smoke test should not last for hours but minutes and test the most crucial

functionality

· 快速發現錯誤並報告錯誤 - 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

· 對每個 Build 都執行冒煙測試 - Be setup to run against every build

· 需要隨著被測試應用程式的修改而不斷修改冒煙測試 - Adapt over time as the application under test evolves

· 作為新建立的自動化測試的基礎模型 - Serve as a model for new test automation

TestComplete Made Easy 》讀書筆記( 5 - 白盒應用程式

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.

.NET Java 程式是基於中間程式碼構建的,所以 TC 可以直接通過反射讀取其中的內部物件、屬性、方法和事件。

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.

C C++ Delphi 這類程式如果在編譯時做相應的設定,則也可以變成 White Box Applications.

TestComplete Made Easy 》讀書筆記( 6 - 建立 Project

可通過 Project Wizard 建立測試專案,其中 Project Item 包括:

· 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.

· 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.

其中 Win32 Tested Application 中可設定被測試應用程式的 Run Mode ,包括 4 種執行模式:

· Simple - Launches the application under the same user account as TestComplete. Parameters can be passed in Simple mode.

· 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.

一般都選擇 Simple ,如果希望在 AQTime 下執行程式以便獲得測試覆蓋率、程式碼執行效率等資訊的話則可選用 Profile

TestComplete Made Easy 》讀書筆記( 7 - Test Log

感覺 TC Test Log 要比 QTP 的做得好些, TC Log 可以寫 6 種類型的資訊:

· 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.

TestComplete Made Easy 》讀書筆記( 8 - Name Mappings

TC 沒有像 QTP 一樣的物件庫以及物件庫管理功能,但是對於那些“又長又臭”的程式碼行,可以通過 Named Mappings Aliases 來縮短程式碼行,並且讓測試物件的命名更加有意義,從而讓錄製和編寫的指令碼更加清晰、直觀易懂。

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

TestComplete Made Easy 》讀書筆記( 9 - 單元測試

TC 支援 5 種單元測試框架,包括:

· 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.

其中 TCUnitTest TC 自己的單元測試框架。 TC 可以整合這幾種測試框架的單元測試,並與其他自動化測試指令碼一起執行。

TestComplete Made Easy 》讀書筆記( 10 - CheckPoint

Region CheckPoint 的例子:

Sub RegionCompareExample

If ( Not Regions .Compare("Logo", Sys .Process("iexplore"). _

Page("http://www.activefocus.net/").Table(0).Cell(1, 0). _

Link(0).Image("nav_r1_c1"), False, False, True , 0)) Then

Call Log .Error("The regions are not identical.")

End If

End Sub

File CheckPoint 的例子:

Sub FileCompareExample

If ( Not Files .Compare("Sample1.txt", "Sample2.txt", 0, True )) Then

Call Log .Error("The files are not identical.")

End If

End Sub

Object CheckPoint 的例子:

Sub ObjectCompareExample

If ( Not Objects .Compare( Sys .Process("iexplore").Page("http://www.activefocus.net/").Panel(0), "Panel", True )) Then

Call Log .Error("The objects are not identical.")

End If

End Sub

TestComplete Made Easy 》讀書筆記( 11 - 資料驅動

TC DDT 來支援資料驅動測試, DDT 包括 3 種類型:

· CVSDriver is used to read text file such as comma delimited (default) or tab delimited (using a schema.ini file). By default the first row is the header information (or column names) for the driver.

Example:

Case,User,Password

1,"admin","admin"