Skip to content

Commit db62495

Browse files
committed
Merged revision(s) 173-181 from utplsql/branches/feature-1:
[feature-requests/1] "Add overall summary for test suite"
1 parent 2a8d7b1 commit db62495

15 files changed

+375
-17
lines changed

documentation/src/reporter.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ <h2><a name="custom"></a>Writing your own Reporter</h2>
9898
PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE);
9999

100100
PROCEDURE close;
101+
102+
PROCEDURE before_suite_results(suite_id IN ut_suite.id%TYPE);
101103

102104
END utMyRssReporter;
103105
/
@@ -164,6 +166,12 @@ <h3>show_error</h3>
164166
<h3>after_errors</h3>
165167
<p>This is called after any errors have been sent for output.</p>
166168

169+
<h3>before_suite_results</h3>
170+
<p>
171+
This is called only when a suite is executed. It displays the overall
172+
banner and suite execution statistics.
173+
</p>
174+
167175
<h2><a name="reportrecords"></a>Outcome and Error records</h2>
168176
<p>
169177
In order to keep the API as simple as possible, many of the procedures defined above take no parameters. In particular, details of the outcome or error which

source/ut_htmlreporter.pkb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,27 @@ Added first version of pluggable reporter packages
142142
pl('</TABLE>');
143143
END;
144144

145+
146+
PROCEDURE before_suite_results(
147+
suite_id ut_suite.id%TYPE
148+
)
149+
IS
150+
PROCEDURE showsuitebanner(
151+
suite_id ut_suite.id%TYPE
152+
)
153+
IS
154+
BEGIN
155+
pl('<H1>SUITE "'|| utsuite.name_from_id(id_in => suite_id) || '": ');
156+
IF utresult.suite_success(suite_id => suite_id) THEN
157+
pl_success;
158+
ELSE
159+
pl_failure;
160+
END IF;
161+
pl('</H1>');
162+
END showsuitebanner;
163+
BEGIN
164+
165+
showsuitebanner(suite_id => suite_id);
166+
END before_suite_results;
145167
END uthtmlreporter;
146168
/

source/ut_htmlreporter.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ $Log
3939
PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE);
4040

4141
PROCEDURE close;
42+
PROCEDURE before_suite_results(
43+
suite_id ut_suite.id%TYPE
44+
);
4245

4346
END uthtmlreporter;
4447
/

source/ut_outputreporter.pkb

Lines changed: 81 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ Added first version of pluggable reporter packages
133133
run_id_in IN utr_outcome.run_id%TYPE := NULL
134134
)
135135
IS
136+
program_name_and_run_id VARCHAR2(2000);
136137
BEGIN
137138
IF success_in
138139
THEN
@@ -196,32 +197,38 @@ Added first version of pluggable reporter packages
196197
END IF;
197198

198199
utreport.pl ('. ');
199-
200-
IF run_id_in IS NOT NULL
200+
program_name_and_run_id := '"'||NVL (program_in, 'Unnamed Test')||'"';
201+
IF run_id_in IS NOT NULL THEN
202+
program_name_and_run_id := program_name_and_run_id ||' Run ID: ' || run_id_in;
203+
END IF;
204+
IF success_in
201205
THEN
202-
utreport.pl ('. Run ID: ' || run_id_in);
206+
utreport.pl (' SUCCESS: ' || program_name_and_run_id);
203207
ELSE
204-
IF success_in
205-
THEN
206-
utreport.pl (' SUCCESS: "' || NVL (program_in, 'Unnamed Test') || '"');
207-
ELSE
208-
utreport.pl (' FAILURE: "' || NVL (program_in, 'Unnamed Test') || '"');
209-
END IF;
208+
utreport.pl (' FAILURE: ' || program_name_and_run_id);
210209
END IF;
211-
212210
utreport.pl ('. ');
213211
END;
214212

215213
PROCEDURE pl (str VARCHAR2)
216214
IS
217215
BEGIN
218216
show(str);
219-
END;
220-
217+
END;
218+
221219
PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE)
222220
IS
221+
v_packagename ut_package.name%TYPE;
222+
v_owner ut_package.owner%TYPE;
223223
BEGIN
224-
showbanner (utresult.success (run_id), utplsql.currpkg, run_id);
224+
IF run_id IS NULL THEN
225+
v_packagename := utplsql.currpkg;
226+
v_owner := utplsql.currpkgowner;
227+
ELSE
228+
v_packagename := utpackage.name_from_last_run_id(last_run_id_in => run_id);
229+
v_owner := utpackage.owner_from_last_run_id(last_run_id_in => run_id);
230+
END IF;
231+
showbanner (utresult.success (run_id), v_owner||'.'||v_packagename, run_id);
225232
utreport.pl ('> Individual Test Case Results:');
226233
utreport.pl ('>');
227234
norows := TRUE;
@@ -280,5 +287,66 @@ Added first version of pluggable reporter packages
280287
END IF;
281288
END;
282289

290+
/*
291+
proc: before_suite_results
292+
Show suite overall result banner and suite run stats
293+
294+
parameters:
295+
suite_id - suite id
296+
*/
297+
PROCEDURE before_suite_results(
298+
suite_id ut_suite.id%TYPE
299+
)
300+
IS
301+
PROCEDURE show_suite_stats(
302+
suite_id ut_suite.id%TYPE
303+
)
304+
IS
305+
SuiteStats utresult.TSuiteStats;
306+
BEGIN
307+
SuiteStats := utresult.get_suite_stats(suite_id => suite_id);
308+
utreport.pl('SUITE STATS: '||to_char(SuiteStats.succeededpackages)||' of '||to_char(SuiteStats.totalpackages)||' packages succeeded.');
309+
utreport.pl('SUITE STATS: '||to_char(SuiteStats.succeededasserts)||' of '||to_char(SuiteStats.totalasserts)||' individual test cases succeeded.');
310+
utreport.pl('.');
311+
END show_suite_stats;
312+
313+
PROCEDURE showsuitebanner(
314+
suite_id ut_suite.id%TYPE
315+
)
316+
IS
317+
BEGIN
318+
IF utresult.suite_success(suite_id => suite_id) THEN
319+
utreport.pl('.');
320+
utreport.pl('> SSSS U U III TTTTTTT EEEEEEE SSSS U U CCC CCC EEEEEEE SSSS SSSS ');
321+
utreport.pl('> S S U U I T E S S U U C C C C E S S S S ');
322+
utreport.pl('> S U U I T E S U U C C C C E S S ');
323+
utreport.pl('> S U U I T E S U U C C E S S ');
324+
utreport.pl('> SSSS U U I T EEEE SSSS U U C C EEEE SSSS SSSS ');
325+
utreport.pl('> S U U I T E S U U C C E S S ');
326+
utreport.pl('> S U U I T E S U U C C C C E S S ');
327+
utreport.pl('> S S U U I T E S S U U C C C C E S S S S ');
328+
utreport.pl('> SSSS UUU III T EEEEEEE SSSS UUU CCC CCC EEEEEEE SSSS SSSS ');
329+
utreport.pl('.');
330+
utreport.pl('SUITE SUCCESS: "'||utsuite.name_from_id(id_in => suite_id)||'"');
331+
ELSE
332+
utreport.pl('.');
333+
utreport.pl('> SSSS U U III TTTTTTT EEEEEEE FFFFFFF AA III L U U RRRRR EEEEEEE ');
334+
utreport.pl('> S S U U I T E F A A I L U U R R E ');
335+
utreport.pl('> S U U I T E F A A I L U U R R E ');
336+
utreport.pl('> S U U I T E F A A I L U U R R E ');
337+
utreport.pl('> SSSS U U I T EEEE FFFF A A I L U U RRRRRR EEEE ');
338+
utreport.pl('> S U U I T E F AAAAAAAA I L U U R R E ');
339+
utreport.pl('> S U U I T E F A A I L U U R R E ');
340+
utreport.pl('> S S U U I T E F A A I L U U R R E ');
341+
utreport.pl('> SSSS UUU III T EEEEEEE F A A III LLLLLLL UUU R R EEEEEEE ');
342+
utreport.pl('.');
343+
utreport.pl('SUITE FAILURE: "'||utsuite.name_from_id(id_in => suite_id)||'"');
344+
END IF;
345+
END showsuitebanner;
346+
347+
BEGIN
348+
showsuitebanner(suite_id => suite_id);
349+
show_suite_stats(suite_id => suite_id);
350+
END before_suite_results;
283351
END;
284352
/

source/ut_outputreporter.pks

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ $Log
3939
PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE);
4040

4141
PROCEDURE close;
42+
PROCEDURE before_suite_results(suite_id ut_suite.id%TYPE);
4243

4344
END;
4445
/

source/ut_package.pkb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,50 @@ Added Standard Headers
7474
THEN
7575
RETURN NULL;
7676
END;
77+
/*
78+
func: name_from_last_run_id
79+
Return name of package using last run id.
80+
Return null if there is no package with given last run id.
81+
params:
82+
last_run_id_in - last run id of package
83+
*/
84+
FUNCTION name_from_last_run_id (last_run_id_in IN ut_package.last_run_id%TYPE)
85+
RETURN ut_package.name%TYPE
86+
IS
87+
retval ut_package.name%TYPE;
88+
BEGIN
89+
SELECT name
90+
INTO retval
91+
FROM ut_package
92+
WHERE last_run_id = last_run_id_in;
93+
RETURN retval;
94+
EXCEPTION
95+
WHEN NO_DATA_FOUND
96+
THEN
97+
RETURN NULL;
98+
END name_from_last_run_id;
99+
/*
100+
func:owner_from_last_run_id
101+
Return owner of package using last run id.
102+
Return null if there is no package with given last run id.
103+
params:
104+
last_run_id_in - last run id of package
105+
*/
106+
FUNCTION owner_from_last_run_id (last_run_id_in IN ut_package.last_run_id%TYPE)
107+
RETURN ut_package.owner%TYPE
108+
IS
109+
retval ut_package.owner%TYPE;
110+
BEGIN
111+
SELECT owner
112+
INTO retval
113+
FROM ut_package
114+
WHERE last_run_id = last_run_id_in;
115+
RETURN retval;
116+
EXCEPTION
117+
WHEN NO_DATA_FOUND
118+
THEN
119+
RETURN NULL;
120+
END owner_from_last_run_id;
77121

78122
PROCEDURE ADD (
79123
suite_in IN INTEGER,

source/ut_package.pks

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ Added Standard Headers
3838
FUNCTION id_from_name (name_in IN ut_package.name%TYPE,
3939
owner_in IN ut_package.owner%TYPE := NULL)
4040
RETURN ut_package.id%TYPE;
41+
FUNCTION name_from_last_run_id(
42+
last_run_id_in IN ut_package.last_run_id%TYPE
43+
)
44+
RETURN ut_package.name%TYPE;
45+
46+
FUNCTION owner_from_last_run_id (last_run_id_in IN ut_package.last_run_id%TYPE)
47+
RETURN ut_package.owner%TYPE;
4148

4249
PROCEDURE ADD (
4350
suite_in IN VARCHAR2,

source/ut_plsql.pkb

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,18 @@ Added Standard Headers
812812
BEGIN
813813
RETURN testpkg.pkg;
814814
END;
815+
816+
/*
817+
func: currpkgowner
818+
Return Owner of current package.
819+
*/
820+
FUNCTION currpkgowner
821+
RETURN VARCHAR2
822+
IS
823+
BEGIN
824+
RETURN testpkg.owner;
825+
END;
826+
815827

816828
PROCEDURE addtest (
817829
package_in IN VARCHAR2,
@@ -923,8 +935,11 @@ Added Standard Headers
923935
)
924936
IS
925937
BEGIN
926-
utresult.show;
927-
938+
IF suite_in IS NULL THEN
939+
utreport.open;
940+
utresult.show;
941+
END IF;
942+
BEGIN
928943
IF NOT per_method_setup_in
929944
THEN
930945
runprog (
@@ -933,6 +948,21 @@ Added Standard Headers
933948
TRUE
934949
);
935950
END IF;
951+
EXCEPTION
952+
WHEN OTHERS THEN
953+
utassert.this (
954+
'Unable to run '
955+
|| v_prefix || c_teardown
956+
|| ': '
957+
|| SQLERRM,
958+
FALSE,
959+
--same as in "runprog" call
960+
null_ok_in=> NULL,
961+
raise_exc_in=> TRUE,
962+
register_in=> TRUE
963+
);
964+
END;
965+
936966

937967
utpackage.upd (
938968
suite_in,
@@ -1095,6 +1125,8 @@ Added Standard Headers
10951125
v_pkg_start DATE;
10961126
v_override VARCHAR2 (1000);
10971127
BEGIN
1128+
utreport.open;
1129+
BEGIN
10981130
IF v_suite IS NULL
10991131
THEN
11001132
utassert.this (
@@ -1153,13 +1185,25 @@ begin
11531185
SYSDATE,
11541186
v_success
11551187
);
1188+
1189+
utresult.showsuite(suite_id => v_suite);
1190+
11561191
END IF;
11571192

11581193
IF reset_results_in
11591194
THEN
11601195
init;
11611196
END IF;
1162-
1197+
utreport.close;
1198+
EXCEPTION
1199+
WHEN OTHERS THEN
1200+
utassert.this (
1201+
'utPLSQL.testsuite failure: '
1202+
|| SQLERRM,
1203+
FALSE
1204+
);
1205+
utreport.close;
1206+
END;
11631207
END;
11641208

11651209
/* Programs used in individual unit test programs. */

source/ut_plsql.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ Added Standard Headers
149149

150150
FUNCTION currpkg
151151
RETURN VARCHAR2;
152+
153+
FUNCTION currpkgowner
154+
RETURN VARCHAR2;
152155

153156
PROCEDURE addtest (
154157
package_in IN VARCHAR2,

source/ut_report.pkb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,22 @@ Added first version of pluggable reporter packages
201201
call('close');
202202
END;
203203

204+
205+
/*
206+
proc: before_suite_results
207+
Show suite overall banner and suite run stats
208+
209+
parameters:
210+
suite_id - suite id
211+
*/
212+
PROCEDURE before_suite_results(
213+
suite_id ut_suite.id%TYPE
214+
)
215+
IS
216+
BEGIN
217+
call('before_suite_results', suite_id);
218+
END before_suite_results;
219+
204220
BEGIN
205221

206222
g_reporter := NVL(utconfig.getreporter, DEFAULT_REPORTER);

source/ut_report.pks

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ $Log
4747
PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE);
4848

4949
PROCEDURE close;
50+
51+
PROCEDURE before_suite_results(suite_id ut_suite.id%TYPE);
5052

5153
END;
5254
/

0 commit comments

Comments
 (0)