跟踪被测应用程序的事件和异常

上一篇 / 下一篇  2007-09-24 17:59:55 / 个人分类:TestComplete

g{RAIq.o0跟踪被测应用程序的事件和异常

uB~BvY7g-c051Testing软件测试网wj#[&h"b ~

陈能技51Testing软件测试网5[,nbzn\2@9Z
2007-9-24

l},k _AlR2b[0

JR"w}D%^6}!}(XX x0在使用TestComplete测试一个应用程序的时候,你可以跟踪程序产生的各种事件并把它们记录到test log中。

7o8q4|3k(ekjlQ;q051Testing软件测试网o6|J0{ x^"H

总览
${$Jx+RIx*D0TC能把debug信息,异常信息,模块加载和卸载,线程创建等事件跟踪记录下来。见下表:

.\q7{ `?0hC ]0

k8?d%])}8vZ0

 Event Type Descrīption
 Create process Message The application under test created a new process.
 Create thread Message The application started a new thread.
 Exception Error An exception occurred in the application under test. If the application was compiled with debug information, the Remarks pane of the Test Log panel will display a call stack for the exception. The DbgServices plug-in includes several options that have effect when exception tracing (see below).
 Exit process Message The process ended.
 Exit thread Message The application finished a thread.
 Load DLL Message The application loaded a dynamic link library.
 Unload DLL Message The application unloaded a dll.
 Output debug string Message The application sent this string to the DbgServices object by calling the OutputDebugString function (Win32 API).

IH&`k0mb051Testing软件测试网t8Zt5r RV:hA

-U r!l Y)v\nm0事件被作为信息输出到log,如下图:

)],OVh9E9Sd0

:V GVYD.G-|1l)p0

x*[a YNPC0u051Testing软件测试网6U/G@+cG4{r%K#|a

51Testing软件测试网 k#Ae'HCl M
使用Debug运行模式
%~{}9gvj2JH0可以用两种方法设置Debug运行模式,一种是在TestdApps编辑窗口,设置Run Mode为Debug,Parameters输入命令行参数和工作目录。51Testing软件测试网6]/^8E _#u8}:p x1|

51Testing软件测试网(P#T\QZ.z1C;q"c

另外一种方式是在脚本中设置,例如下面的脚本
5w'_8AI.s"`3FQeW0var
q%n'H8`5B+K0  MyApp : OleVariant;
.w9d+Q2Z0Ap*q0begin51Testing软件测试网rj8y?&M
  // Obtains the tested application
a NWLhn[q\&U:z0  MyApp := TestedApps.MyTestedApp;51Testing软件测试网 s+zoaH D
  51Testing软件测试网:m5mFj tW S"L$z%U
  // Specifies the run mode parameters
$h"g ~"I4hIk X0  MyApp.Params.DebugParams.CommandLineParameters := '-t -e';
(bz#h%s3[0  MyApp.Params.DebugParams.WorkFolder := 'C:\MyFolder';51Testing软件测试网u F%O6_w_T

D'A_!gIpT-D\,?F0  51Testing软件测试网W%J&[VH @)`
  // Activates the Debug run mode51Testing软件测试网/p@RNFXx
  MyApp.Params.DebugParams.Activate;51Testing软件测试网/nZnNo4ba
  ...
o:^~7d`}:b)z}Y0end;51Testing软件测试网 g;G_A Fk[ D!Ih

51Testing软件测试网n&z?S-}"b

使用DbgServices对象
9c g#I%qkg*y0使用DbgServices对象的各种方法,例如LaunchTestedApplication、LaunchAllTestedApplications、LaunchApplication、AttachToProcess,可以让TC附加到被测应用程序的运行进程并把debug进程权限赋给TC,从而使你可以跟踪应用程序的事件和异常信息。51Testing软件测试网-mJQ`%RO"?s"QE

51Testing软件测试网6Y ?$av hB Xy

使用这种方式与使用Debug运行模式是类似的效果,但是提供了以下便利:
7[MC;FhL0支持任何运行模式的应用程序,而不仅仅是包括在项目的TestedApp里的应用程序。51Testing软件测试网U X*v~0v1m M
它让你可以附加到一个运行在操作系统的进程并监视它所发生的事件。51Testing软件测试网*^)Kxf]Yu"C+s
如果你使用RunAs运行模式,然后使用LaunchTestedApplication或LaunchAllTestedApplications方法来运行程序,TC会用Debug模式在指定的用户账号下运行被测程序。(也就是说你可以在另外一个用户账号下debug程序)。

h Zd#{W~"H051Testing软件测试网&m9~!n'~(dDi*VD

下面是个关于使用DbgServices的例子:51Testing软件测试网3G/tW)qz2dO+oy
  p := DbgServices.LaunchTestedApplication[0];
E6`'B|-JM{s0l0  w := p.WaitWindow('TfrmDebugServices', 'Debug Services', 1, 10000);
Jb;|iH$dE0 
fwM"zNy:o9p0  DbgServices.Options.EnableEvents := True;

(B;l.Cqa.\ D0

^-V@-P.P~3V0  DbgServices.Options.ActiveExceptions := True;
;Kv^^ OZ3Ss%x0  Log.Message('Exceptions are being traced.');
a6z*Ue4c @1w0  w.Window('TButton', 'Test All').ClickButton;51Testing软件测试网2L VWW(h V
  Delay(2000);
k;HrBdB9x*G V X] R0 
~6P)d#b@8Q0  DbgServices.Options.ActiveExceptions := False;
)vs srv U.c9lX0  Log.Message('Exceptions are not traced.');51Testing软件测试网c4f-VYH
  w.Window('TButton', 'Exception').Click;
3TYn#mgr0s bFZR0  w.Close;

czfc.WG0

.k)PG pE3\6^^'cF%@:~.i0  repeat
SO:m0b2`3`0    Delay(500);51Testing软件测试网m"PJv|oU&v+l
  until not p.Exists;51Testing软件测试网0G!e|p"CO$mc%pL(B
51Testing软件测试网X \ D O`Y


TAG: Testcomplete 事件跟踪 异常跟踪 TestComplete

 

评分:0

我来说两句

Open Toolbar