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

Skip to content

Commit 0d03adf

Browse files
committed
fixed bug generating extra suitefinished message for teamcity reporter
added reporting stdout for Teamcity added test for Teamcity reporting stdout
1 parent b7f7c8c commit 0d03adf

6 files changed

Lines changed: 115 additions & 4 deletions

File tree

source/core/ut_output_buffer.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ create or replace package body ut_output_buffer is
102102
l_lines := ut_output_buffer.get_lines_cursor(a_reporter_id, a_timeout_sec);
103103
loop
104104
fetch l_lines into l_line;
105-
dbms_output.put_line(l_line);
106105
exit when l_lines%notfound;
106+
dbms_output.put_line(l_line);
107107
end loop;
108108
close l_lines;
109109
end;

source/reporters/ut_documentation_reporter.tpb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ create or replace type body ut_documentation_reporter is
6666
failed_test_running_count := failed_test_running_count + 1;
6767
self.print_red_text(l_message || ' (FAILED - '||failed_test_running_count||')');
6868
end if;
69+
70+
-- reproduce the output from before/after procedures and the test
6971
print_output(a_test.before_each);
7072
print_output(a_test.before_test);
7173
print_output(a_test.item);

source/reporters/ut_teamcity_reporter.tpb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ create or replace type body ut_teamcity_reporter is
5151
overriding member procedure after_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test) is
5252
l_assert ut_assert_result;
5353
l_test_full_name varchar2(4000);
54+
procedure print_output(a_exectable ut_executable) is
55+
l_lines ut_varchar2_list;
56+
begin
57+
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
58+
l_lines := ut_utils.clob_to_table(a_exectable.serveroutput);
59+
for i in 1..l_lines.count loop
60+
self.print_text(l_lines(i));
61+
end loop;
62+
end if;
63+
end;
5464
begin
5565
-- l_test_full_name := self.suite_names_stack(self.suite_names_stack.last) || ':' ||
5666
-- nvl(replace(a_test.description, '.'), a_test.name);
@@ -59,6 +69,13 @@ create or replace type body ut_teamcity_reporter is
5969
if a_test.result = ut_utils.tr_ignore then
6070
self.print_text(ut_teamcity_reporter_helper.test_ignored(l_test_full_name));
6171
else
72+
73+
-- reproduce the output from before/after procedures and the test
74+
print_output(a_test.before_each);
75+
print_output(a_test.before_test);
76+
print_output(a_test.item);
77+
print_output(a_test.after_test);
78+
print_output(a_test.after_each);
6279

6380
if a_test.results is not null and a_test.results.count > 0 then
6481
for i in 1 .. a_test.results.count loop

tests/RunAll.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ create table ut$test_table (val varchar2(1));
152152
@@lib/RunTest.sql ut_test/ut_test.BeforeEachProcedureNameInvalid.sql
153153
@@lib/RunTest.sql ut_test/ut_test.BeforeEachProcedureNameNull.sql
154154
@@lib/RunTest.sql ut_test/ut_test.TestOutputGathering.sql
155+
@@lib/RunTest.sql ut_test/ut_test.TestOutputGatheringForTeamcity.sql
155156

156157
@@lib/RunTest.sql ut_test_suite/ut_test_suite.ErrorsATestWhenAfterTestFails.sql
157158
@@lib/RunTest.sql ut_test_suite/ut_test_suite.ErrorsATestWhenBeforeTestFails.sql

tests/ut_test/ut_test.TestOutputGathering.sql

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,21 @@ end;
5858
declare
5959
l_output_data dbms_output.chararr;
6060
l_num_lines integer := 100000;
61+
l_output clob;
6162
begin
6263
--act
6364
ut.run('ut_output_tests');
6465

6566
--assert
6667
dbms_output.get_lines( l_output_data, l_num_lines);
68+
dbms_lob.createtemporary(l_output,true);
6769
for i in 1 .. l_num_lines loop
68-
if l_output_data(i) like '%<!beforeeach!>%<!beforetest!>%<!thetest!>%<!aftertest!>%<!aftereach!>%1 tests, 0 failed, 0 errored%' then
69-
:test_result := ut_utils.tr_success;
70-
end if;
70+
dbms_lob.append(l_output,l_output_data(i));
7171
end loop;
72+
73+
if l_output like '%<!beforeeach!>%<!beforetest!>%<!thetest!>%<!aftertest!>%<!aftereach!>%1 tests, 0 failed, 0 errored%' then
74+
:test_result := ut_utils.tr_success;
75+
end if;
7276

7377
if :test_result != ut_utils.tr_success or :test_result is null then
7478
for i in 1 .. l_num_lines loop
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
create or replace package ut_output_tests
2+
as
3+
--%suite
4+
5+
--%beforeeach
6+
procedure beforeeach;
7+
8+
--%aftereach
9+
procedure aftereach;
10+
11+
--%test
12+
--%beforetest(beforetest)
13+
--%aftertest(aftertest)
14+
procedure ut_passing_test;
15+
16+
procedure beforetest;
17+
18+
procedure aftertest;
19+
20+
end;
21+
/
22+
23+
create or replace package body ut_output_tests
24+
as
25+
26+
procedure beforetest as
27+
begin
28+
dbms_output.put_line('<!beforetest!>');
29+
end;
30+
31+
procedure aftertest
32+
as
33+
begin
34+
dbms_output.put_line('<!aftertest!>');
35+
end;
36+
37+
procedure beforeeach as
38+
begin
39+
dbms_output.put_line('<!beforeeach!>');
40+
end;
41+
42+
procedure aftereach
43+
as
44+
begin
45+
dbms_output.put_line('<!aftereach!>');
46+
end;
47+
48+
procedure ut_passing_test
49+
as
50+
begin
51+
dbms_output.put_line('<!thetest!>');
52+
ut.expect(1,'Test 1 Should Pass').to_equal(1);
53+
end;
54+
55+
end;
56+
/
57+
58+
declare
59+
l_output_data dbms_output.chararr;
60+
l_num_lines integer := 100000;
61+
l_output clob;
62+
begin
63+
--act
64+
ut.run('ut_output_tests',ut_teamcity_reporter);
65+
66+
--assert
67+
dbms_output.get_lines( l_output_data, l_num_lines);
68+
dbms_lob.createtemporary(l_output,true);
69+
for i in 1 .. l_num_lines loop
70+
dbms_lob.append(l_output,l_output_data(i));
71+
end loop;
72+
if l_output like '%##teamcity[testStarted%<!beforeeach!>%<!beforetest!>%<!thetest!>%<!aftertest!>%<!aftereach!>%##teamcity[testFinished%' then
73+
:test_result := ut_utils.tr_success;
74+
end if;
75+
76+
if :test_result != ut_utils.tr_success or :test_result is null then
77+
for i in 1 .. l_num_lines loop
78+
dbms_output.put_line(l_output_data(i));
79+
end loop;
80+
dbms_output.put_line('Failed: Wrong output');
81+
end if;
82+
end;
83+
/
84+
85+
drop package ut_output_tests
86+
/
87+

0 commit comments

Comments
 (0)