source: trunk/NewView/unittests/NewViewTests.pas@ 196

Last change on this file since 196 was 196, checked in by RBRi, 18 years ago

improved output

File size: 2.7 KB
Line 
1program Main;
2
3uses
4 Classes,
5 SysUtils,
6 TestAssert,
7 CmdLineParameterUnitTests,
8 CharUtilsUnitTests,
9 StringUtilsUnitTests,
10 FileUtilsUnitTests,
11 HelpTopicTests,
12 VersionUnit;
13
14IMPORTS
15 FUNCTION PmPrintfString(aString:PChar):BYTE; APIENTRY; 'PMPRINTF' NAME 'PmPrintfString';
16END;
17
18VAR
19 tmpSuites : TList;
20 tmpTests : TList;
21 tmpAllTests : TList;
22 tmpAllExceptions : TStringList;
23 tmpFunction : FUNCTION : TList;
24 tmpTestNoParam : String;
25 tmpTest : PROCEDURE;
26 i,j,tmpTestCount,tmpFailureCount,tmpErrorCount,tmpTestNo : integer;
27 tmpStartTime, tmpEndTime : TDateTime;
28
29BEGIN
30 tmpAllTests := TList.Create;
31 tmpSuites := TList.Create;
32 tmpAllExceptions := TStringList.Create;
33
34 write('UnitTest for NewView version ' + GetAppVersion);
35
36 tmpTestNoParam := ParamStr(1);
37 writeln(tmpTestNoParam);
38
39 tmpSuites.Add(@getCmdLineParameterUnitTests);
40 tmpSuites.Add(@getCharUtilsUnitTests);
41 tmpSuites.Add(@getStringUtilsUnitTests);
42// tmpSuites.Add(@getHelpTopicTests);
43 tmpSuites.Add(@getFileUtilsUnitTests);
44
45 tmpTestNo := -1;
46 try
47 tmpTestNo := StrToInt(tmpTestNoParam);
48 tmpTestNo := tmpTestNo;
49 // no parameter or empty
50 if 0 = tmpTestNo then tmpTestNo := -1;
51 except
52 end;
53
54 tmpTestCount := 0;
55 tmpFailureCount := 0;
56 tmpErrorCount := 0;
57 tmpStartTime := now;
58
59 for i := 0 to tmpSuites.Count-1 do
60 begin
61 tmpFunction := tmpSuites.items[i];
62 tmpTests := tmpFunction;
63
64 for j := 0 to tmpTests.Count-1 do
65 begin
66 tmpTestCount := tmpTestCount + 1;
67 tmpTest := tmpTests.items[j];
68 if (0 > tmpTestNo)
69 OR (tmpTestNo = tmpTestCount)
70 then
71 begin
72 try
73 tmpTest;
74 Write('.');
75 except
76 on e:EAssertFailed do
77 begin
78 tmpFailureCount := tmpFailureCount + 1;
79 tmpAllExceptions.add('# ' + IntToStr(tmpTestCount) + ' ' + e.message);
80 end;
81 on e:Exception do
82 begin
83 tmpErrorCount := tmpErrorCount + 1;
84 tmpAllExceptions.add('# ' + IntToStr(tmpTestCount) + ' ' + e.message);
85 end;
86 end;
87 if (0 = tmpTestCount MOD 50) then writeln;
88 end;
89 end;
90 end;
91
92 tmpEndTime := now;
93
94 writeln;
95 for i := 0 to tmpAllExceptions.count-1 do
96 begin
97 writeln(tmpAllExceptions[i]);
98 end;
99
100 if (0 > tmpTestNo) then
101 write('Tests run: ' + IntToStr(tmpTestCount))
102 else
103 write('Test #' + IntToStr(tmpTestNo) + ':');
104 write(', Failures: ' + IntToStr(tmpFailureCount));
105 write(', Errors: ' + IntToStr(tmpErrorCount));
106 write(', Time elapsed: ' + FormatDateTime('hh:nn:ss', tmpEndTime - tmpStartTime));
107 writeln;
108
109END.
Note: See TracBrowser for help on using the repository browser.