您的位置:首页 > 移动开发

《TestComplete Made Easy》读书笔记

2010-01-09 09:31 363 查看

TestComplete Made Easy
》下载:
http://blog.csdn.net/Testing_is_believing/archive/2009/08/07/4423777.aspx http://blog.csdn.net/Testing_is_believing/archive/2008/06/27/2593108.aspx
 


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
安装

 

可到
www.AutomatedQA.com

下载
TC
的最新版本。

 

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"

2,"user1","pass1"

·
ExcelDriver

is used to read
an Excel spreadsheet. The first row of the sheet is the header information for
the driver.

·
ADODriver

is a generic
driver to read in
ADO

compatible data source.

 

DDT
中几个常用的方法和属性:

·
ColumnCount

: The number of
column in the data source.

·
ColumnName

: The name of a
given column from the data source.

·
Name

: The Name of
the Driver.

·
Value

: Returns the
value of a column based on the column name or index.

·
EOF

: Indicates if
the driver is at the end of the data source.

·
DriveMethod

: Iterates
through all the records of the database, and executes a script routine for each
records.

·
Next

: Move to the
next record in the data source

 

一个数据驱动的例子:

Dim

MyDriver

Sub

Main

Dim

SQLStatement

Dim

ConnectionString

' Start Notepad

TestedApps

.Notepad.Run

' Limit to 100 records

SQLStatement = "SELECT TOP
(100) CustomerID, FirstName, LastName FROM" & _

"
Sales.vIndividualCustomer"

ConnectionString =
"Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _

"Persist Security
Info=False;" & _

"Initial
Catalog=AdventureWorks;Data Source=./SQLExpress"

' Create Driver

Set

MyDriver =
DDT

.ADODriver(ConnectionString,SQLStatement)

' Call Method 100 times

MyDriver.DriveMethod("Unit1.Test1")

End Sub


 


Sub

Test1

Dim

p1

Dim

w1

Dim

w2

Dim

KeyStr

Set

p1 =
Sys

.Process("Notepad")

Set

w1 = p1.Window("Notepad", "*")

Set

w2 = w1.Window("Edit")

w2.VScroll.Pos = 0

' Create String with Customer
Information

KeyStr =
MyDriver.Value("CustomerID")& "," & _

MyDriver.Value("FirstName")&
"," & _

MyDriver.Value("LastName")&
"[Enter]"

Call

w2.Keys( KeyStr)

End Sub

 


TestComplete Made Easy
》读书笔记(
12

- Event Handling

 


QTP
中有“
Recovery Scenario
”,在
TC
中则有
Event Handling


Events occur based on certain actions and
activities that occur in TestComplete, or some otherapplication that is being
tested. For example, every time an error is logged (by TestComplete or your script),
TestComplete generates an
OnLogError


event.

 

TC

中可处理的一般事件包括:


OnLogCloseNode
Occurs
when a log folder is pop off the log.

OnLogCreateNode       
Occurs
when a new log folder is appended on the log.

OnLogError                 
Occurs
when an error message is posted to the log.

OnLogEvent                
Occurs
when an event message is posted to the log.

OnLogFile                   
Occurs
when a file is posted to the log.

OnLogLink                  
Occurs
when a file reference (link) is posted to the log.

OnLogMessage           
Occurs
when a information message is posted to the log.

OnLogPicture              
Occurs
when a picture (image) is posted to the log.

OnLogWarning            
Occurs
when a warning message is posted to the log.

OnOverlappingWindow  
Occurs
when a overlapping window appears.

OnTimeout                  
Occurs
when a timeout expires in a project or project suite.

OnUnexpectedWindow 
Occurs
when an unexpected window appears.

OnValidate                  
Occurs
when the objects Validate method is called.

 

下面的脚本用于处理
OnLogError
事件,当
Log
一个错误时,把当前的桌面截屏并写入日志:

Sub

GeneralEvents_OnLogError(Sender, LogParams)

Call

Log

.Picture(
Sys

.Desktop,LogParams.Str)

End Sub


 


TestComplete Made Easy
》读书笔记(
13

- ADO

 

TC
可通过两种方式访问
ADO
数据源:


1

Microsoft

CreateCommand

CreateConnection


2

Borland

CreateADOCommand

CreateADOConnection

CreateADODataSet

CreateADOQuery

CreateADOStoredProc

CreateADOTable

 

ADO
的一般使用步骤:

1. Create an Connection to the database.

2. Open the Connection.

3. Create an Query Command.

4. Execute the Query Command.

5. Do something with the returned RecordSet.

6. Close the Connection.

 

下面是一个简单的使用例子:

Sub

Main

' Create a new Connection
object

Set AConnection =
ADO

.CreateConnection

' Note that you can also
create an
ADO
connection using the following code:

' Set AConnection =
CreateObject("ADODB.Connection")

' Specify the connection
string

AConnection.ConnectionString =
_

"Provider=SQLOLEDB.1;Integrated
Security=SSPI;" & _

"Persist Security
Info=False;" & _

"Initial
Catalog=AdventureWorks;Data Source=./SQLExpress"

' Activate the connection

AConnection.Open

' Create a new Command object

Set

Cmd =
ADO

.CreateCommand

' To create an
ADO
command you can also use the following code:

' Set Cmd =
CreateObject("ADODB.Command")

' Specify the connection

Cmd.ActiveConnection =
AConnection

' Specify command type and
text

Cmd.CommandText = _

"SELECT CustomerID,
TerritoryID, AccountNumber, CustomerType," & _

" rowguid, ModifiedDate
FROM Sales.Customer WHERE (CustomerType = ?)"

Cmd.CommandType = adCmdText

' Create a new parameter

Set Prm =
Cmd.CreateParameter("@CustType",
DB

.adVarChar,
DB

.adParamInput)

' Specify the parameter value

Prm.Size= 1

Prm.Value = "S"

Cmd.Parameters.Append(Prm)

' Execute the command

Set

RecSet = Cmd.Execute

' Execute the command

RecSet.MoveFirst

While Not

RecSet.EOF

Log

.Message(RecSet("CustomerID").Value & " has account
" & _

RecSet("AccountNumber").Value)

RecSet.MoveNext

WEnd


AConnection.Close

End Sub

 

 


TestComplete Made Easy
》读书笔记(
14

- Web
测试

 

TC
支持
4
种类型的
WEB
页面模型:

·
DOM

- Document
Object Model, the native way that Internet Explorer looks at web pages. The DOM
model creates a very flat tree in the Object Browser. All items on the web page
need to be re-read each time the web page is updated. This is the slowest
method for using web pages.

·
TAG

- All HTML
elements are sorted by their TAG value. If a link (<A> HTML tag) gets
created, only the "A" node part of the Object Browser tree gets
updated.

·
Tree

- Treats a web
page like a normal application. This model creates a very deep tree for most web
pages. This is the fastest method for using web pages.

·
Hybrid

- This uses
both DOM and Tree. All new recording will use the Tree model, while any old TestComplete
code using the DOM will continue to work.

 


TC
中可创建两种专门针对
WEB

checkpoint



1

Web Comparison
checkpoint

A Web Comparison checkpoint is used to compare two web
pages.

Web Comparison checkpoint
包括
3
种方式:

·
Compare entire page

-
The whole HTML page is save and is compared.

·
Compare only tab structure

-
Only tag names are compared, not attributes, attributes' values and elements'
values.

·
Compare only specified tags

-
Only the selected elements will be compared.

o
Compare links

- Only A
elements are compared (text and attributes of the element are compare as well).

o
Compare images

- Only IMG
elements are compared.

o
Compare input elements

- Only INPUT
elements are compare.

 


2

Web
Accessibility Checkpoint

verify accessibility compliance.

Web Accessibility Checkpoint
可检查以下方面的可访问性的遵循情况:

·
Check "alt" attribute

-
All IMG, APPLET, AREA and INPUT elements must have a non-empty ALT attribute.

·
Check "mailto:"

-
Web page must have at least one A element (link), whose HREF attribute starts
with mailto:

·
Check image sizes

- All IMG
elements must have the WIDTH and HEIGHT attributes specified.

·
Check "title" tag

-
The web page must have a non-empty TITLE elment.

·
Check tab indexes

- All INPUT,
SELECT, and TEXTAREA elements must have the TABINDEX attribute.

·
Check link accessibility

-
Checks for broken links.

·
Check ActiveX objects

-
Verifies there are no ActiveX objects on the web page.

·
Check Applet object

-
Verifies there are no Applet objects on the web page.

·
Check multimedia links

-
Verifies there are not AVI or SWF files on the web page.

·
Check server-side images

-
Verifies that none of the IMG elements contain SRC attribute with parameters.

 


TestComplete Made Easy
》读书笔记(
15

-
查找
Web
页面元素

 


TC
中,可使用两种方式查找
Web
页面元素:


1

NativeWebObject.Find()

方法


下面是一个简单的例子:

Sub

NativeFind

Dim

PageObj

Dim

ProductLink

Set

PageObj =
Sys

.Process("iexplore").

Page("http://www.automatedqa.com/")

Set

ProductLink =
PageObj.NativeWebObject.Find("title","Products","A")

if

ProductLink.Exists
Then


ProductLink.Click

End If


End Sub


 


2

TestedObject.Find()

方法


下面是一个简单的例子:

Sub

TestedObjFind

Dim

PropArray, ValuesArray

Dim

PageObj

Dim

ProductLink

' Creates arrays of
properties and values

PropArray =
CreateVariantArray(0, 1)

ValuesArray =
CreateVariantArray(0, 1)

' Specifies property names

PropArray(0) =
"title"

PropArray(1) =
"tagName"

' Specifies the property
values

ValuesArray(0) =
"Products"

ValuesArray(1) = "A"

Set

PageObj =
Sys

.Process("iexplore").Page("http://www.automatedqa.com/")

Set

ProductLink = PageObj.Find(PropArray,ValuesArray,3)

if

ProductLink.Exists
Then


ProductLink.Click

End If


End Sub


 


TestComplete Made Easy
》读书笔记(
16

- HTTP
性能测试

 

通过录制产生
Task
,然后创建性能测试场景,例如:

Sub

Test1

Dim

HTTPTask

Dim

VirtualUser

Set

HTTPTask =
LoadTesting

.HTTPTaskByName("Task")

Set

VirtualUser =
LoadTesting

.CreateVirtualUser("VirtualUser1")

Set

VirtualUser.Task = HTTPTask

Call

VirtualUser.Run("Task")

End Sub


 

参数化的例子:

Sub

Test1

Dim

HTTPTask

Dim Request

Dim

VirtualUser

Set

HTTPTask =
LoadTesting

.HTTPTaskByName("Order")

Set

Request = HTTPTask.Connection(0).Request(0)

Randomize


Request.Variables.Item("paints")
= Int(1000 * Rnd()) + 1

Request.Variables.Item("pencils")
= Int(1000 * Rnd()) + 1

Request.Variables.Item("albums")
= Int(1000 * Rnd()) + 1

Set

VirtualUser =
LoadTesting

.CreateVirtualUser("VirtualUser1")

Set

VirtualUser.Task = HTTPTask

Call

VirtualUser.Run("Order")

End Sub


 

也可以在
OnLoadTestingRequest

事件中进行参数化,例如:

Sub

Test1

Dim

HTTPTask

Dim

VirtualUser

Set

HTTPTask =
LoadTesting

.HTTPTaskByName("Task")

HTTPTask.Connection(0).Request(0).RequestEventTrigger
= True

Set

VirtualUser =
LoadTesting

.CreateVirtualUser("VirtualUser1")

Set

VirtualUser.Task = HTTPTask

Call

VirtualUser.Run("Task")

End Sub


 

Sub

GeneralEvents_OnLoadTestingRequest(Sender,
User, Request)

Request.Variables.Item("paints")
= Int(1000 * Rnd()) + 1

Request.Variables.Item("pencils")
= Int(1000 * Rnd()) + 1

Request.Variables.Item("albums")
= Int(1000 * Rnd()) + 1

End Sub


 

TC
通过
Remote Agent
来分配
HTTP
压力的产生任务。


TestComplete Made Easy
》读书笔记(
17

-
分布式测试

 

TC
通过
Network Suites
来支持分布式测试。

 

什么是分布式测试:
Distributed
Testing is the ability of TestComplete to control test cases running on several
computers at the same time.

 

创建分布式测试需要注意:


1

In order to
perform a distributed test, all projects involved must contain the Network
Suite project item.


2

all the
computers involved must have the same version of TestComplete/TestExecute on
them (including the minor version number).

 

同步点:
SynchPoints
delay execution of the test until all computers with that synch point name
reach the synchronization point. When all the computers with a named SynchPoint
hit that Synchronize Point, they will continue on with their test.

 

如果希望模拟多个用户同时编辑一条记录的情况,则可以使用
SynchPoints


 

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐