Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 74b9d33

Browse files
committed
Refactored ut_teamcity_reporter_printer to become ut_teamcity_reporter_helper.
Now it is a set of functions returning the outcomes to be printed. This allows the reporter to keep control over the output used.
1 parent 1a329ed commit 74b9d33

6 files changed

Lines changed: 69 additions & 64 deletions

File tree

source/install.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ whenever oserror exit failure rollback
130130
@@reporters/ut_dbms_output_suite_reporter.tps
131131
@@reporters/ut_dbms_output_suite_reporter.tpb
132132
@@reporters/ut_teamcity_reporter.tps
133-
@@reporters/ut_teamcity_reporter_printer.pks
134-
@@reporters/ut_teamcity_reporter_printer.pkb
133+
@@reporters/ut_teamcity_reporter_helper.pks
134+
@@reporters/ut_teamcity_reporter_helper.pkb
135135
@@reporters/ut_teamcity_reporter.tpb
136136

137137
@@legacy/ut_assert.pks

source/reporters/ut_teamcity_reporter.tpb

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@ create or replace type body ut_teamcity_reporter is
99
overriding member procedure before_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_object) is
1010
l_test_object ut_test_object := treat(a_suite as ut_test_object);
1111
begin
12-
13-
ut_teamcity_reporter_printer.test_suite_started(a_suite_name => coalesce(replace(l_test_object.name, '.')
14-
,l_test_object.object_name));
12+
self.print(
13+
ut_teamcity_reporter_helper.test_suite_started(
14+
a_suite_name => coalesce(replace(l_test_object.name, '.')
15+
,l_test_object.object_name))
16+
);
1517
end before_suite;
1618

1719
overriding member procedure after_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_object) is
1820
l_test_object ut_test_object := treat(a_suite as ut_test_object);
1921
begin
20-
ut_teamcity_reporter_printer.test_suite_finished(a_suite_name => coalesce(replace(l_test_object.name, '.')
21-
,l_test_object.object_name));
22+
self.print(
23+
ut_teamcity_reporter_helper.test_suite_finished(
24+
a_suite_name => coalesce(replace(l_test_object.name, '.')
25+
,l_test_object.object_name))
26+
);
2227
end after_suite;
2328

2429
overriding member procedure before_suite_item(self in out nocopy ut_teamcity_reporter, a_suite in ut_object, a_item_index pls_integer) is
@@ -34,7 +39,7 @@ create or replace type body ut_teamcity_reporter is
3439
l_test := treat(l_item as ut_test);
3540
l_test_full_name := nvl(replace(l_suite.name, '.'), l_suite.object_name) || ':' ||
3641
nvl(replace(l_test.name, '.'), l_test.object_name);
37-
ut_teamcity_reporter_printer.test_started(a_test_name => l_test_full_name);
42+
self.print(ut_teamcity_reporter_helper.test_started(a_test_name => l_test_full_name));
3843
end if;
3944

4045
end before_suite_item;
@@ -59,7 +64,7 @@ create or replace type body ut_teamcity_reporter is
5964
nvl(replace(l_item.name, '.'), l_test.object_name);
6065

6166
if l_test.result = ut_utils.tr_ignore then
62-
ut_teamcity_reporter_printer.test_ignored(l_test_full_name);
67+
self.print(ut_teamcity_reporter_helper.test_ignored(l_test_full_name));
6368
else
6469

6570
if l_test.items is not null and l_test.items.count > 0 then
@@ -68,22 +73,22 @@ create or replace type body ut_teamcity_reporter is
6873
l_assert := treat(l_test.items(i) as ut_assert_result);
6974

7075
if nvl(l_assert.result, ut_utils.tr_error) != ut_utils.tr_success then
71-
ut_teamcity_reporter_printer.test_failed(a_test_name => l_test_full_name
72-
,a_msg => l_assert.message
73-
,a_expected => l_assert.expected_value_string
74-
,a_actual => l_assert.actual_value_string);
76+
self.print(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name
77+
,a_msg => l_assert.message
78+
,a_expected => l_assert.expected_value_string
79+
,a_actual => l_assert.actual_value_string));
7580
exit;
7681
end if;
7782

7883
end loop;
7984
elsif l_test.result = ut_utils.tr_failure then
80-
ut_teamcity_reporter_printer.test_failed(a_test_name => l_test_full_name, a_msg => 'Test failed');
85+
self.print(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name, a_msg => 'Test failed'));
8186
elsif l_test.result = ut_utils.tr_error then
82-
ut_teamcity_reporter_printer.test_failed(a_test_name => l_test_full_name, a_msg => 'Error occured');
87+
self.print(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name, a_msg => 'Error occured'));
8388
end if;
8489

85-
ut_teamcity_reporter_printer.test_finished(l_test_full_name
86-
,a_test_duration_milisec => trunc(l_test.execution_time * 1e3));
90+
self.print(ut_teamcity_reporter_helper.test_finished(l_test_full_name
91+
,a_test_duration_milisec => trunc(l_test.execution_time * 1e3)));
8792

8893
end if;
8994

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create or replace package body ut_teamcity_reporter_printer is
1+
create or replace package body ut_teamcity_reporter_helper is
22

33
subtype t_prop_index is varchar2(2000 char);
44
type t_props is table of varchar2(32767) index by t_prop_index;
@@ -8,7 +8,7 @@ create or replace package body ut_teamcity_reporter_printer is
88
return regexp_replace(a_value, '(''|"|' || chr(13) || '|' || chr(10) || '|[|])', '|\1');
99
end;
1010

11-
procedure message(a_command in varchar2, a_props t_props default cast(null as t_props)) is
11+
function message(a_command in varchar2, a_props t_props default cast(null as t_props)) return varchar2 is
1212
l_message varchar2(32767);
1313
l_index t_prop_index;
1414
l_value varchar2(32767);
@@ -25,42 +25,42 @@ create or replace package body ut_teamcity_reporter_printer is
2525
l_index := a_props.next(l_index);
2626
end loop;
2727
l_message := l_message || ']';
28-
sys.dbms_output.put_line(l_message);
29-
28+
return l_message;
29+
3030
end message;
3131

32-
procedure block_opened(a_name varchar2, a_flow_id varchar2 default null) is
32+
function block_opened(a_name varchar2, a_flow_id varchar2 default null) return varchar2 is
3333
l_props t_props;
3434
begin
3535
l_props('name') := a_name;
3636
l_props('flowId') := a_flow_id;
37-
message('blockOpened', l_props);
37+
return message('blockOpened', l_props);
3838
end;
3939

40-
procedure block_closed(a_name varchar2, a_flow_id varchar2 default null) is
40+
function block_closed(a_name varchar2, a_flow_id varchar2 default null) return varchar2 is
4141
l_props t_props;
4242
begin
4343
l_props('name') := a_name;
4444
l_props('flowId') := a_flow_id;
45-
message('blockClosed', l_props);
45+
return message('blockClosed', l_props);
4646
end;
4747

48-
procedure test_suite_started(a_suite_name varchar2, a_flow_id varchar2 default null) is
48+
function test_suite_started(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2 is
4949
l_props t_props;
5050
begin
5151
l_props('name') := a_suite_name;
5252
l_props('flowId') := a_flow_id;
53-
message('testSuiteStarted', l_props);
53+
return message('testSuiteStarted', l_props);
5454
end;
55-
procedure test_suite_finished(a_suite_name varchar2, a_flow_id varchar2 default null) is
55+
function test_suite_finished(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2 is
5656
l_props t_props;
5757
begin
5858
l_props('name') := a_suite_name;
5959
l_props('flowId') := a_flow_id;
60-
message('testSuiteFinished', l_props);
60+
return message('testSuiteFinished', l_props);
6161
end;
6262

63-
procedure test_started(a_test_name varchar2, a_capture_standard_output boolean default null, a_flow_id varchar2 default null) is
63+
function test_started(a_test_name varchar2, a_capture_standard_output boolean default null, a_flow_id varchar2 default null) return varchar2 is
6464
l_props t_props;
6565
begin
6666
l_props('name') := a_test_name;
@@ -73,26 +73,26 @@ create or replace package body ut_teamcity_reporter_printer is
7373
null
7474
end;
7575
l_props('flowId') := a_flow_id;
76-
message('testStarted', l_props);
76+
return message('testStarted', l_props);
7777
end;
7878

79-
procedure test_finished(a_test_name varchar2, a_test_duration_milisec number default null, a_flow_id varchar2 default null) is
79+
function test_finished(a_test_name varchar2, a_test_duration_milisec number default null, a_flow_id varchar2 default null) return varchar2 is
8080
l_props t_props;
8181
begin
8282
l_props('name') := a_test_name;
8383
l_props('duration') := a_test_duration_milisec;
8484
l_props('flowId') := a_flow_id;
85-
message('testFinished', l_props);
85+
return message('testFinished', l_props);
8686
end;
8787

88-
procedure test_ignored(a_test_name varchar2, a_flow_id varchar2 default null) is
88+
function test_ignored(a_test_name varchar2, a_flow_id varchar2 default null) return varchar2 is
8989
l_props t_props;
9090
begin
9191
l_props('name') := a_test_name;
9292
l_props('flowId') := a_flow_id;
93-
message('testIgnored', l_props);
93+
return message('testIgnored', l_props);
9494
end;
95-
procedure test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) is
95+
function test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) return varchar2 is
9696
l_props t_props;
9797
begin
9898
l_props('name') := a_test_name;
@@ -105,34 +105,34 @@ create or replace package body ut_teamcity_reporter_printer is
105105
l_props('expected') := a_expected;
106106
end if;
107107

108-
message('testFailed', l_props);
108+
return message('testFailed', l_props);
109109
end;
110-
procedure test_std_out(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) is
110+
function test_std_out(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2 is
111111
l_props t_props;
112112
begin
113113
l_props('name') := a_test_name;
114114
l_props('out') := a_out;
115115
l_props('flowId') := a_flow_id;
116-
message('testStdOut', l_props);
116+
return message('testStdOut', l_props);
117117
end;
118-
procedure test_std_err(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) is
118+
function test_std_err(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2 is
119119
l_props t_props;
120120
begin
121121
l_props('name') := a_test_name;
122122
l_props('out') := a_out;
123123
l_props('flowId') := a_flow_id;
124-
message('testStdErr', l_props);
124+
return message('testStdErr', l_props);
125125
end;
126126

127-
procedure custom_message(a_text in varchar2, a_status in varchar2, a_error_deatils in varchar2 default null, a_flow_id in varchar2 default null) is
127+
function custom_message(a_text in varchar2, a_status in varchar2, a_error_deatils in varchar2 default null, a_flow_id in varchar2 default null) return varchar2 is
128128
l_props t_props;
129129
begin
130130
l_props('text') := a_text;
131131
l_props('status') := a_status;
132132
l_props('errorDetails') := a_error_deatils;
133133
l_props('flowId') := a_flow_id;
134-
message('message', l_props);
134+
return message('message', l_props);
135135
end;
136136

137-
end ut_teamcity_reporter_printer;
137+
end ut_teamcity_reporter_helper;
138138
/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create or replace package ut_teamcity_reporter_helper is
2+
3+
function block_opened(a_name varchar2, a_flow_id varchar2 default null) return varchar2;
4+
function block_closed(a_name varchar2, a_flow_id varchar2 default null) return varchar2;
5+
6+
function test_suite_started(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2;
7+
function test_suite_finished(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2;
8+
9+
function test_started(a_test_name varchar2, a_capture_standard_output boolean default null, a_flow_id varchar2 default null) return varchar2;
10+
function test_finished(a_test_name varchar2, a_test_duration_milisec number default null, a_flow_id varchar2 default null) return varchar2;
11+
function test_ignored(a_test_name varchar2, a_flow_id varchar2 default null) return varchar2;
12+
function test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) return varchar2;
13+
function test_std_out(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2;
14+
function test_std_err(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2;
15+
16+
function custom_message(a_text in varchar2, a_status in varchar2, a_error_deatils in varchar2 default null, a_flow_id in varchar2 default null) return varchar2;
17+
18+
end ut_teamcity_reporter_helper;
19+
/

source/reporters/ut_teamcity_reporter_printer.pks

Lines changed: 0 additions & 19 deletions
This file was deleted.

source/uninstall.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
drop package ut_teamcity_reporter_printer;
1+
drop package ut_teamcity_reporter_helper;
22

33
drop package ut_suite_manager;
44

0 commit comments

Comments
 (0)