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

Skip to content

Commit e6a6a4c

Browse files
committed
Improvements to teamcity reporter (used by DataGrip and IntelliJ - JetBrains IDEs)
The reporter will now report all errors and all failed expectations. The test description will be used instead of test name.
1 parent 69092f2 commit e6a6a4c

4 files changed

Lines changed: 58 additions & 19 deletions

File tree

source/reporters/ut_teamcity_reporter.tpb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,28 @@ create or replace type body ut_teamcity_reporter is
108108
ut_teamcity_reporter_helper.test_failed(
109109
a_test_name => l_test_full_name,
110110
a_msg => 'Error occured',
111-
a_details =>
112-
trim(l_std_err_msg)
113-
|| case when a_test.failed_expectations is not null
114-
and a_test.failed_expectations.count>0
115-
then a_test.failed_expectations(1).message end
111+
a_details => trim(l_std_err_msg)
116112
)
117113
);
114+
for i in 1 .. a_test.failed_expectations.count loop
115+
ut_utils.append_to_list(
116+
l_results,
117+
ut_teamcity_reporter_helper.test_failed(
118+
a_test_name => l_test_full_name,
119+
a_msg => a_test.failed_expectations(i).description,
120+
a_details => a_test.failed_expectations(i).message )
121+
);
122+
end loop;
118123
elsif a_test.failed_expectations is not null and a_test.failed_expectations.count > 0 then
119-
-- Teamcity supports only a single failure message
120-
121-
ut_utils.append_to_list(
122-
l_results,
123-
ut_teamcity_reporter_helper.test_failed(
124-
a_test_name => l_test_full_name,
125-
a_msg => a_test.failed_expectations(a_test.failed_expectations.first).description,
126-
a_details => a_test.failed_expectations(a_test.failed_expectations.first).message )
127-
);
124+
for i in 1 .. a_test.failed_expectations.count loop
125+
ut_utils.append_to_list(
126+
l_results,
127+
ut_teamcity_reporter_helper.test_failed(
128+
a_test_name => l_test_full_name,
129+
a_msg => a_test.failed_expectations(i).description,
130+
a_details => a_test.failed_expectations(i).message )
131+
);
132+
end loop;
128133
elsif a_test.result = ut_utils.gc_failure then
129134
ut_utils.append_to_list(
130135
l_results,

source/reporters/ut_teamcity_reporter_helper.pkb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ create or replace package body ut_teamcity_reporter_helper is
7373
'true'
7474
when false then
7575
'false'
76-
else
77-
null
7876
end;
7977
l_props('flowId') := a_flow_id;
8078
return message('testStarted', l_props);

test/ut3_user/reporters/test_teamcity_reporter.pkb

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,26 @@ create or replace package body test_teamcity_reporter as
3131
end;
3232
end;]';
3333

34+
execute immediate q'[create or replace package check_multiple_failures is
35+
--%suite
36+
37+
--%test
38+
procedure multi_failure;
39+
end;]';
40+
execute immediate q'[create or replace package body check_multiple_failures is
41+
procedure multi_failure is
42+
begin
43+
ut3_develop.ut.expect(1).to_be_null;
44+
ut3_develop.ut.expect(2).to_equal(1);
45+
ut3_develop.ut.expect('Bad').to_equal('Good');
46+
end;
47+
end;]';
48+
3449
end;
3550

3651

3752
procedure report_produces_expected_out is
3853
l_output_data ut3_develop.ut_varchar2_list;
39-
l_output clob;
4054
l_expected varchar2(32767);
4155
begin
4256
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='org']
@@ -84,7 +98,6 @@ create or replace package body test_teamcity_reporter as
8498

8599
procedure escape_special_chars is
86100
l_output_data ut3_develop.ut_varchar2_list;
87-
l_output clob;
88101
l_expected varchar2(32767);
89102
begin
90103
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='A suite with |'quote|'']
@@ -103,7 +116,6 @@ create or replace package body test_teamcity_reporter as
103116

104117
procedure trims_long_output is
105118
l_output_data ut3_develop.ut_varchar2_list;
106-
l_output clob;
107119
l_expected varchar2(32767);
108120
begin
109121
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_trims_long_output']
@@ -120,11 +132,32 @@ create or replace package body test_teamcity_reporter as
120132
ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected);
121133
end;
122134

135+
procedure report_mutiple_expectations is
136+
l_output_data ut3_develop.ut_varchar2_list;
137+
l_expected varchar2(32767);
138+
begin
139+
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_multiple_failures']
140+
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_user.check_multiple_failures.multi_failure']
141+
%##teamcity[testFailed timestamp='%' details='Actual: 1 (number) was expected to be null' name='ut3_user.check_multiple_failures.multi_failure']
142+
%##teamcity[testFailed timestamp='%' details='Actual: 2 (number) was expected to equal: 1 (number)' name='ut3_user.check_multiple_failures.multi_failure']
143+
%##teamcity[testFailed timestamp='%' details='Actual: |'Bad|' (varchar2) was expected to equal: |'Good|' (varchar2)' name='ut3_user.check_multiple_failures.multi_failure']
144+
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_user.check_multiple_failures.multi_failure']
145+
%##teamcity[testSuiteFinished timestamp='%' name='check_multiple_failures']}';
146+
--act
147+
select *
148+
bulk collect into l_output_data
149+
from table(ut3_develop.ut.run('check_multiple_failures',ut3_develop.ut_teamcity_reporter()));
150+
151+
--assert
152+
ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected);
153+
end;
154+
123155
procedure remove_test_package is
124156
pragma autonomous_transaction;
125157
begin
126158
execute immediate 'drop package check_escape_special_chars';
127159
execute immediate 'drop package check_trims_long_output';
160+
execute immediate 'drop package check_multiple_failures';
128161
end;
129162

130163
end;

test/ut3_user/reporters/test_teamcity_reporter.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ create or replace package test_teamcity_reporter as
1515
--%test(Trims output so it fits into 4000 chars)
1616
procedure trims_long_output;
1717

18+
--%test(Reports failures on multiple expectations)
19+
procedure report_mutiple_expectations;
20+
1821
--%afterall
1922
procedure remove_test_package;
2023

0 commit comments

Comments
 (0)