3Q$g~'a FBCz]0添加需要比较的文件有以下3种方法:51Testing软件测试网X#J"x&XSv[0K
M
$KA
s
Y x
?0//1.Add files from the Files editor
Ge2m4HE [ y'l-m)P0//2.Add files from the Project Explorer
pM6V@i"~wR#[0//3.Add files from scrīpts
YF G7pa&u2`,R0G;lrpF
NlQ
W0在TC里,封装了好几个文件比较的方法,主要有以下几种:51Testing软件测试网7KQB:uNXq&z)D-J
//4.Comparing files by bytes
,lX |e:z?&pM0//使用正则表达式比较文件(RegExpr)51Testing软件测试网.aD{p3q,J+~\;X}
//5.Comparing files with variable parts51Testing软件测试网9WoM:NUZ
P-d|Q
(?:R9g;M5`MH0具体使用如下:51Testing软件测试网ep"W*D%mvu3d3Uz8Y4k
c.y z
j-|0procedure AddfileFromscrīpt;51Testing软件测试网"WG2P
`S%t7{`wA5|
begin51Testing软件测试网
Q2@l,z5H9{+E
if not Files.Add('..\..\TestFile_old.txt', 'TestFile_old') then51Testing软件测试网'u1aPQ$J0d#pP%l
Log.Message(Files.LastError);51Testing软件测试网 @l@%]r;OS
TN
if not Files.Add('..\..\TestFile_new.txt', 'TestFile_new') then51Testing软件测试网pq1Y?v"~
Log.Message(Files.LastError);
2zz h r?9T*T*~0 if not Files.Add('..\..\TestFile_new_space.txt', 'TestFile_new_space') then51Testing软件测试网"MBNy3z
Log.Message(Files.LastError);51Testing软件测试网)PgJ3lK}E|
end;
[e{?*x2j1W+qS03\HJls6b0//获取文件方式
8AHd j C1j4|K0//FileNameByIndex、FileNameByName、NameByIndex 、NameByFileName 、FileNamesList、NamesList
d9khT2U"ZSjJT0procedure GetFile;
#Gs,PT8c3d0begin
E9y~L2|s P\]0 showmessage(Files.FileNameByIndex(0));51Testing软件测试网0hn|8G6~
ol
end;51Testing软件测试网1k[.Bab^H
+A \j+z!nN|-j0//常用比较文件方式
*A4Q8`y)z6gas}0procedure ComparefileBytes;51Testing软件测试网u\a[:pB3c"c
begin51Testing软件测试网 EMV,MKC$m
if not Files.Compare(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new')) then
B,ywSYcwTb0 showmessage(files.LastError);
6q.r2s4~ }6R's(b0end;
FsO7\#n
HN9n-W051Testing软件测试网jz,yEx
?//通过Hash值比较文件51Testing软件测试网u*O}:X(me)X$?
j1t
procedure ComparefileHash;51Testing软件测试网-I\;i4~9qV
var Hash : OleVariant;//Hash记录两个文件的差异值
T;t0HB#al0BYM0begin51Testing软件测试网/C@T:}2^6ez^4C
Hash := Files.CalculateHashValue(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new_space'));51Testing软件测试网%L^0J4]'@!I8[H
if not Files.Compare(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new_space'),Hash) then51Testing软件测试网!`e6T+Y_YqX
showmessage(files.LastError)51Testing软件测试网KY~B8KK
else showmessage('The two files is equal!');
}1n8haQ!lKn0end;
'L+mC
ZNp;r$f06R-E8NRh2N0procedure Test_Sample;
4WD~Ei`?0begin
I%o9e `G `"F4ZW+GN0 Aliases.TCSampleForm.Drag(224, 17, 162, 0);
$wG4d6Xm0 Aliases.TCSampleSys.Process('Explorer').Window('Shell_TrayWnd').Window('ReBarWindow32').Window('MSTaskSwWClass', '运行应用程序').Window('ToolbarWindow32', '运行应用程序').CheckItem('TestComplete - C:\Documents and Settings\temp\桌面\hzr-TechED\TCSamples\TCSamples', -1, false);51Testing软件测试网y`BH|(lG
end;
iV*A1cYA
yaf)V0