@@ -2,13 +2,13 @@ create or replace type body ut_documentation_reporter is
22 /*
33 utPLSQL - Version X.X.X.X
44 Copyright 2016 - 2017 utPLSQL Project
5-
5+
66 Licensed under the Apache License, Version 2.0 (the "License"):
77 you may not use this file except in compliance with the License.
88 You may obtain a copy of the License at
9-
9+
1010 http://www.apache.org/licenses/LICENSE-2.0
11-
11+
1212 Unless required by applicable law or agreed to in writing, software
1313 distributed under the License is distributed on an "AS IS" BASIS,
1414 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,6 +29,18 @@ create or replace type body ut_documentation_reporter is
2929 return rpad(' ', self.lvl * 2);
3030 end tab;
3131
32+ member procedure print_output(a_executable ut_executable) is
33+ l_lines ut_varchar2_list;
34+ begin
35+ if a_executable is not null and a_executable.is_defined and a_executable.serveroutput is not null and
36+ dbms_lob.getlength(a_executable.serveroutput) > 0 then
37+ l_lines := ut_utils.clob_to_table(a_executable.serveroutput);
38+ for i in 1 .. l_lines.count loop
39+ self.print_text(l_lines(i));
40+ end loop;
41+ end if;
42+ end;
43+
3244 overriding member procedure print_text(self in out nocopy ut_documentation_reporter, a_text varchar2) is
3345 begin
3446 if a_text is not null then
@@ -38,35 +50,25 @@ create or replace type body ut_documentation_reporter is
3850
3951 overriding member procedure before_calling_suite(self in out nocopy ut_documentation_reporter, a_suite ut_logical_suite) as
4052 begin
41- self.print_text( coalesce( a_suite.description, a_suite.name ) );
53+ self.print_text(coalesce(a_suite.description, a_suite.name) );
4254 lvl := lvl + 1;
4355 end;
4456
4557 overriding member procedure after_calling_test(self in out nocopy ut_documentation_reporter, a_test ut_test) as
4658 l_message varchar2(4000);
47-
48- procedure print_output(a_exectable ut_executable) is
49- l_lines ut_varchar2_list;
50- begin
51- if a_exectable is not null and a_exectable.is_defined and a_exectable.serveroutput is not null and dbms_lob.getlength(a_exectable.serveroutput) > 0 then
52- l_lines := ut_utils.clob_to_table(a_exectable.serveroutput);
53- for i in 1..l_lines.count loop
54- self.print_text(l_lines(i));
55- end loop;
56- end if;
57- end;
59+
5860 begin
59- l_message := coalesce( a_test.description, a_test.name );
61+ l_message := coalesce(a_test.description, a_test.name);
6062 --if test failed, then add it to the failures list, print failure with number
6163 if a_test.result = ut_utils.tr_ignore then
6264 self.print_yellow_text(l_message || ' (IGNORED)');
6365 elsif a_test.result = ut_utils.tr_success then
6466 self.print_green_text(l_message);
6567 elsif a_test.result > ut_utils.tr_success then
6668 failed_test_running_count := failed_test_running_count + 1;
67- self.print_red_text(l_message || ' (FAILED - '|| failed_test_running_count|| ')');
69+ self.print_red_text(l_message || ' (FAILED - ' || failed_test_running_count || ')');
6870 end if;
69-
71+
7072 -- reproduce the output from before/after procedures and the test
7173 print_output(a_test.before_each);
7274 print_output(a_test.before_test);
@@ -75,6 +77,15 @@ create or replace type body ut_documentation_reporter is
7577 print_output(a_test.after_each);
7678 end;
7779
80+ overriding member procedure after_calling_after_all(self in out nocopy ut_documentation_reporter, a_suite in ut_logical_suite) is
81+ begin
82+ self.print_output(treat(a_suite as ut_suite).after_all);
83+ end;
84+ overriding member procedure after_calling_before_all(self in out nocopy ut_documentation_reporter, a_suite in ut_logical_suite) is
85+ begin
86+ self.print_output(treat(a_suite as ut_suite).before_all);
87+ end;
88+
7889 overriding member procedure after_calling_suite(self in out nocopy ut_documentation_reporter, a_suite ut_logical_suite) as
7990 begin
8091 lvl := lvl - 1;
@@ -85,7 +96,7 @@ create or replace type body ut_documentation_reporter is
8596
8697 overriding member procedure after_calling_run(self in out nocopy ut_documentation_reporter, a_run in ut_run) as
8798 l_summary_text varchar2(4000);
88- l_warnings ut_varchar2_list := ut_varchar2_list();
99+ l_warnings ut_varchar2_list := ut_varchar2_list();
89100 procedure print_failure_for_assert(a_assert ut_assert_result) is
90101 l_lines ut_varchar2_list;
91102 begin
@@ -96,12 +107,13 @@ create or replace type body ut_documentation_reporter is
96107 self.print_cyan_text(a_assert.caller_info);
97108 self.print_text(' ');
98109 end;
99-
110+
100111 procedure print_failures_for_test(a_test ut_test, a_failure_no in out nocopy integer) is
101112 begin
102113 if a_test.result > ut_utils.tr_success then
103114 a_failure_no := a_failure_no + 1;
104- self.print_text(lpad(a_failure_no, length(failed_test_running_count)+2,' ')||') '||nvl( a_test.name, a_test.item.form_name ));
115+ self.print_text(lpad(a_failure_no, length(failed_test_running_count) + 2, ' ') || ') ' ||
116+ nvl(a_test.name, a_test.item.form_name));
105117 self.lvl := self.lvl + 3;
106118 for j in 1 .. a_test.results.count loop
107119 if a_test.results(j).result > ut_utils.tr_success then
@@ -111,79 +123,81 @@ create or replace type body ut_documentation_reporter is
111123 lvl := lvl - 3;
112124 end if;
113125 end;
114-
126+
115127 procedure print_failures_from_suite(a_suite ut_logical_suite, a_failure_no in out nocopy integer) is
116128 begin
117129 for i in 1 .. a_suite.items.count loop
118- if a_suite.items(i) is of (ut_logical_suite) then
119- print_failures_from_suite(treat( a_suite.items(i) as ut_logical_suite), a_failure_no);
120- elsif a_suite.items(i) is of (ut_test) then
130+ if a_suite.items(i) is of(ut_logical_suite) then
131+ print_failures_from_suite(treat(a_suite.items(i) as ut_logical_suite), a_failure_no);
132+ elsif a_suite.items(i) is of(ut_test) then
121133 print_failures_for_test(treat(a_suite.items(i) as ut_test), a_failure_no);
122134 end if;
123135 end loop;
124136 end;
125-
137+
126138 procedure print_failures_details(a_run in ut_run) is
127139 l_failure_no integer := 0;
128140 begin
129141 if a_run.results_count.failure_count > 0 or a_run.results_count.errored_count > 0 then
130-
131- self.print_text( 'Failures:' );
132- self.print_text( ' ' );
142+
143+ self.print_text('Failures:');
144+ self.print_text(' ');
133145 for i in 1 .. a_run.items.count loop
134146 print_failures_from_suite(treat(a_run.items(i) as ut_logical_suite), l_failure_no);
135147 end loop;
136148 end if;
137149 end;
138-
139- procedure print_warnings(a_run in ut_run) is
150+
151+ procedure print_warnings(a_run in ut_run) is
140152 procedure gather_warnings(a_item ut_suite_item) is
141153 l_suite ut_logical_suite;
142154 begin
143155 --process warnings of child items first
144156 if a_item is of(ut_logical_suite) then
145157 l_suite := treat(a_item as ut_logical_suite);
146- for item_ind in 1.. l_suite.items.count loop
158+ for item_ind in 1 .. l_suite.items.count loop
147159 gather_warnings(l_suite.items(item_ind));
148160 end loop;
149161 end if;
150-
162+
151163 --then process self warnings
152164 if a_item.warnings is not null and a_item.warnings.count > 0 then
153- for warn_ind in 1.. a_item.warnings.count loop
165+ for warn_ind in 1 .. a_item.warnings.count loop
154166 l_warnings.extend;
155- l_warnings(l_warnings.last) := ' '||l_warnings.last||') '||a_item.path||' - '||
156- regexp_replace(a_item.warnings(warn_ind),'('||chr(10)||'|'||chr(13)||')','\1 ');
167+ l_warnings(l_warnings.last) := ' ' || l_warnings.last || ') ' || a_item.path || ' - ' ||
168+ regexp_replace(a_item.warnings(warn_ind)
169+ ,'(' || chr(10) || '|' || chr(13) || ')'
170+ ,'\1 ');
157171 end loop;
158172 end if;
159173 end;
160174 begin
161- if a_run.items is not null and a_run.items.count >0 then
162- for run_item in 1.. a_run.items.count loop
175+ if a_run.items is not null and a_run.items.count > 0 then
176+ for run_item in 1 .. a_run.items.count loop
163177 gather_warnings(a_run.items(run_item));
164178 end loop;
165179 end if;
166-
167- if l_warnings.count> 0 then
168- self.print_text( 'Warnings:' );
169- self.print_text( ' ' );
180+
181+ if l_warnings.count > 0 then
182+ self.print_text('Warnings:');
183+ self.print_text(' ');
170184 for i in 1 .. l_warnings.count loop
171185 self.print_text(l_warnings(i));
172186 self.print_text(' ');
173187 end loop;
174188 end if;
175189 end;
176-
190+
177191 begin
178192 print_failures_details(a_run);
179193 print_warnings(a_run);
180- self.print_text( 'Finished in '|| a_run.execution_time|| ' seconds' );
181- l_summary_text :=
182- a_run.results_count.total_count || ' tests , '
183- ||a_run.results_count.failure_count||' failed, '
184- ||a_run.results_count.errored_count||' errored, '
185- ||a_run.results_count.ignored_count||' ignored.'||
186- case when l_warnings.count>0 then ' '||l_warnings.count||' warning(s)' end;
194+ self.print_text('Finished in ' || a_run.execution_time || ' seconds');
195+ l_summary_text := a_run.results_count.total_count || ' tests, ' || a_run.results_count.failure_count || ' failed, ' ||
196+ a_run.results_count.errored_count || ' errored , ' || a_run.results_count.ignored_count ||
197+ ' ignored.' || case
198+ when l_warnings.count > 0 then
199+ ' ' || l_warnings.count || ' warning(s)'
200+ end;
187201 if a_run.results_count.failure_count > 0 then
188202 self.print_red_text(l_summary_text);
189203 else
0 commit comments