QTP中的Test Object Model(测试对象模型)--双语版
上一篇 / 下一篇 2009-09-14 16:00:40 / 个人分类:转贴好文
一、
r of+_,Z Cq"xD v0About Understanding the Test Object Model51Testing软件测试网5|8X7ogip/WZ
关于了解测试对象模型
QuickTest tests your dynamically changing application by learning and identifying test objects and their expected properties and values. During recording QuickTest analyzes each object in your application much the same way that a person would look at a photograph and remember its details.51Testing软件测试网!V0I7r#UY
QuickTest通过记住和标识测试对象及其预期的属性和属性值,对动态更改的应用程序进行测试。在录制期间,QuickTest对应用程序中每个对象进行分析的方式与一个人看一张图片然后记住其细节的方式大致相同。
#O,\@ }^4X? ?0In the following narrative you will be introduced to the concepts related to the test object model and how QuickTest uses the information it gathers to test your application.51Testing软件测试网:q-db|I2?5J%m4l[
在以下叙述中,将向您介绍与测试模型相关的概念,以及QuickTest如何使用它所收集的信息来测试应用程序。
^3w4tC;}/@J01、
n{'yp f#Cfn0Understanding How QuickTest Learns Objects While Recording
6|v/Es/h"J:oH0了解QuickTest如何在录制时记住对象
bTJ+B5hC0QuickTest learns objects just as you would.
A6P"~#O6fl0QuickTest像您那样记住对象。
5x)K*?!zP^;WP3D~0For example, suppose as part of an experiment, Jonny is told that he will be shown a photograph of a picnic scene for a few seconds during which someone will point out one item in the picture. Jonny is told that he will be expected to identify that item again in identical or similar pictures one week from today.51Testing软件测试网mC#R;_P]h
例如,假定作为实验的一部分,Jonny被通知将向他展示一张野餐场景的图片,时间为几秒钟,在此期间,将会有人指出图片中的一个项目。自今天起一周后,Jonny需要在相同或相似的图片中再次识别出该项目。
t5\N2TG+L!w3Tk
CI0Before he is shown the photograph, Jonny begins preparing himself for the test by thinking about which characteristics he wants to learn about the item that the tester indicates. Obviously, he will automatically note whether it is a person, inanimate object, animal, or plant. Then, if it is a person, he will try to commit to memory the gender, skin color, and age. If it is an animal, he will try to remember the type of animal, its color, and so forth.51Testing软件测试网+RB"] DpG%{
在看到图片之前,Jonny自己开始为测试做准备,考虑对于测试者指出的项目,需要记住该项目的哪些特征。显然,他将自动记住该项目是人、无生命物体、动物还是植物。如果是人,他将尝试记住其性别、肤色和年龄。如果是动物,他将尝试记住其类型、颜色等。
The tester shows the scene to Jonny and points out one of three children sitting on a picnic blanket. Jonny notes that it is a caucasian girl about 8 years old. In looking at the rest of the picture, however, he realizes that one of the other children in the picture could also fit that description. In addition to learning his planned list of characteristics, he also notes that the girl he is supposed to identify has long, brown hair.51Testing软件测试网B#t_1nzre!?
测试者向Jonny展示场景,并从三个坐在野餐毯上的孩子中指定一个。Jonny注意到这是一个8岁左右的白种女孩。但在查看图片中的其他内容时,他意识到图片中的另一个孩子也符合这种描述。除了记住计划的特征列表以外,Jonny还记下自己应该识别出的这个女孩留着褐色的长发。
G8e8J1yw-A1~!n0Now that only one person in the picture fits the characteristics he learned, he is fairly sure that he will be able to identify the girl again, even if the scene the tester shows him next week is slightly different.51Testing软件测试网(E&W)K vEn,nI!f~/m ~/v
注意:图片中只有一个人符合他记住的特征,所以,即使测试者下周展示的场景稍有不同,他也相当肯定能够再次识别出这个女孩。
Since he still has a few moments left to look at the picture, he attempts to notice other, more subtle differences between the child he is supposed to remember and the others in the picture—just in case.51Testing软件测试网!B$\k0kg+rL"\VY`
由于还剩下一点看图片的时间,因此,只是为了以防万一,Jonny试着注意自己应该记住的这个孩子与图片中其他孩子之间更细微的差别。
If the two similar children in the picture appeared to be identical twins, Jonny might also take note of some less permanent feature of the child, such as the child's position on the picnic blanket. That would enable him to identify the child if he were shown another picture in which the children were sitting on the blanket in the same order.
)R"Ui3XQ)~{
e0如果图片中两个相似的孩子看上去像一对双胞胎,那么Jonny还会记下这个孩子的一些不那么永久的特征,如这个孩子在野餐毯上的位置。这样,如果向他展示的另一张图片中,这些孩子仍按相同的顺序坐在毯子上,他也能够识别出这个孩子。
4[t4hvmJ0QuickTest uses a very similar method when it learns objects during the recording process.
-vL%yH(i-z*|a0QuickTest采用了极为类似的方法,以便在录制过程中记住对象。
First, it "looks" at the object on which you are recording and stores it as a test object, determining in which test object class it fits. Just as Jonny immediately checked whether the item was a person, animal, plant, or thing. QuickTest might classify the test object as a standard Windows dialog box (Dialog), a Web button (WebButton), or a Visual Basic scroll bar object (VbScrollBar), for example.51Testing软件测试网.H$V`1~`i
首先,它将“观看”您要录制的对象,然后将其作为测试对象进行存储,确定该对象符合的测试对象类。正如Jonny会立即检查项目是人、动物、植物还是东西,QuickTest也会对测试对象进行分类,例如,标准Windows对话框(Dialog)、Web按钮(WebButton)或Visual Basic滚动条对象(VbScrollBar)。
#[#?la
gB0Then, for each test object class, QuickTest has a list of mandatory properties that it always learns; similar to the list of characteristics that Jonny planned to learn before seeing the picture. When you record on an object, QuickTest always learns these default property values, and then "looks" at the rest of the objects on the page, dialog box, or other parent object to check whether this description is enough to uniquely identify the object. If it is not, QuickTest adds assistive properties, one by one, to the description, until it has compiled a unique description; like when Jonny added the hair length and color characteristics to his list. If no assistive properties are available, or if those available are not sufficient to create a unique description, QuickTest adds a special ordinal identifier, such as the object's location on the page or in the source code, to create a unique description, just as Jonny would have remembered the child's position on the picnic blanket if two of the children in the picture had been identical twins.51Testing软件测试网4sE(Ab$_2V
y}
然后,对于每个测试对象类,QuickTest都有一个始终要记住的强制属性的列表,类似于Jonny在看到图片之前计划要记住的特征的列表。当您录制对象时,QuickTest始终记住这些默认的属性值,然后“视图”页面上其余的对象、对话框或其他父对象,以检查该描述是否足以唯一标识该对象。如果不足以进行唯一标识,QuickTest将向该描述中逐项添加辅助属性,直到经过编译成为唯一的描述为止,就像Jonny向他的列表中添加头发的长度和颜色特征一样。如果没有可用的辅助属性,或者那些可用的辅助属性仍不足够创建一个唯一的描述,QuickTest将添加一个特殊的顺序标识符(例如页面上或源代码中对象的位置)以创建唯一的描述,正如图片中的两个孩子是一对双胞胎时,Jonny要记注孩子在野餐毯上的位置一样。
$CW%vtQ0
@P'ZM8pfJ02、51Testing软件测试网t3S+O9f6F4l*\
Understanding How QuickTest Identifies Objects During the Run Session
0x$C`QjvgO0了解QuickTest如何在运行会话过程中标识对象
w#g:u(D.q/a2SJ?a0QuickTest also uses a very human-like technique for identifying objects during the run session.51Testing软件测试网'l'l+g0]$Yy
在运行会话期间,QuickTest也会像人那样采用类似的技术来标识对象。
!|S+P]/s%r
j_0Suppose as a continuation to the experiment, Jonny is now asked to identify the same "item" he initially identified but in a new, yet similar environment.
*cNzh
W xe0假定继续该实验,现在Jonny需要在一个新的、但仍然相似的环境中识别出同一个“项目”。
~/o1]U"[ H0The first photograph he is shown is the original photograph. He searches for the same caucasian girl, about eight years old, with long, brown hair that he was asked to remember and immediately picks her out. In the second photograph, the children are playing on the playground equipment, but Jonny is still able to easily identify the girl using the same criteria.51Testing软件测试网 m1DY
c3oW;~lQZ
他所看到的第一张图片是原来的图片。他需要找出原来要求他记住的这个相同的留着褐色长发、大约8岁的白种女孩,并能立即指出这个女孩。在第二张图片中,这些孩子们正在操场设备上玩,但Jonny仍然能够使用相同的条件很容易地识别出这个女孩。
W'`hi!M2kt3\
cy0Similarly, during a run session, QuickTest searches for a run-time object that exactly matches the description of the test object it learned while recording. It expects to find a perfect match for both the mandatory and any assistive properties it used to create a unique description while recording. As long as the object in the application does not change significantly, the description learned during recording is almost always sufficient for QuickTest to uniquely identify the object. This is true for most objects, but your application could include objects that are more difficult to identify during subsequent run sessions.51Testing软件测试网g7v \i.ze
同样,在运行会话期间,QuickTest也会搜索与录制时记住的测试对象的描述完全匹配的运行时对象。它需要找到与录制时用于创建唯一描述的强制属性和任何辅助属性完全匹配的对象。只要应用程序中的对象没有较大的改变,录制过程中记住的描述几乎总是足以使QuickTest唯一标识出该对象。对于大部分对象,这种方法是适用的,但应用程序中包含的某些对象可能在后续运行会话期间很难标识。
Consider the final phase of Jonny's experiment. In this phase, the tester shows Jonny another photograph of the same family at the same location, but the children are older and there are also more children playing on the playground. Jonny first searches for a girl with the same characteristics he used to identify the girl in the other pictures (the test object), but none of the caucasian girls in the picture have long, brown hair. Luckily, Jonny was smart enough to remember some additional information about the girl's appearance when he first saw the picture the previous week. He is able to pick her out (the run-time object), even though her hair is now short and dyed blond.
{m#O!T PF?0考虑Jonny实验中的最后一个阶段。在该阶段中,测试者向Jonny展示了另一张图片,同一个家庭在同一个位置,但孩子们都长大了,并且还有许多孩子正在操场上玩。Jonny首先会通过与他用来在其他图片中识别出这个女孩(测试对象)的相同的特征来查找这个女孩,但图片中并没有留着褐色长发的白种女孩。不过很幸运,在上周第一次看到图片时,聪明的Jonny还记住了有关这个女孩外貌的其他一些信息。即使现在女孩的头发剪短了,并染成了金色,他仍然能够指出这个女孩(运行时对象)。