Skip to content

Commit 320b3b0

Browse files
authored
Merge pull request #1251 from utPLSQL/feature/improvements_to_teamcity_reporter
Support multiple expectation failures with teamcity reporter
2 parents 46e0a8e + 73e9cf3 commit 320b3b0

File tree

7 files changed

+104
-25
lines changed

7 files changed

+104
-25
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ jobs:
5858
oracle-sid: 'XE'
5959
oracle-version: "gvenzl/oracle-xe:21-slim"
6060
oracle-base: '/opt/oracle'
61+
- id: 7
62+
db_version_name: '23free'
63+
oracle-sid: 'FREEPDB1'
64+
oracle-version: "gvenzl/oracle-free:23-slim"
65+
oracle-base: '/opt/oracle'
6166

6267
services:
6368
html_checker:

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.pkb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ as
9090

9191
procedure erroring_test
9292
is
93-
l_variable integer;
93+
l_integer_variable integer;
9494
begin
9595
dbms_output.put_line('<!erroring test!>');
96-
l_variable := 'a string';
97-
ut3_develop.ut.expect(l_variable).to_equal(1);
96+
l_integer_variable := 'a string';
9897
end;
9998

10099
procedure disabled_test

test/ut3_user/reporters/test_documentation_reporter.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Failures:
3737
%
3838
%
3939
2) erroring_test
40-
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
40+
ORA-06502: PL/SQL: %: character to number conversion error
4141
ORA-06512: at "UT3_USER.TEST_REPORTERS", line 44%
4242
ORA-06512: at line 6
4343
Finished in % seconds

test/ut3_user/reporters/test_teamcity_reporter.pkb

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,37 @@ 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+
40+
--%test
41+
procedure multi_failure_on_error;
42+
end;]';
43+
execute immediate q'[create or replace package body check_multiple_failures is
44+
procedure multi_failure is
45+
begin
46+
ut3_develop.ut.expect(1).to_be_null;
47+
ut3_develop.ut.expect(2).to_equal(1);
48+
ut3_develop.ut.expect('Bad').to_equal('Good');
49+
end;
50+
procedure multi_failure_on_error is
51+
l_integer_variable integer;
52+
begin
53+
ut3_develop.ut.expect(1).to_be_null;
54+
ut3_develop.ut.expect(2).to_equal(1);
55+
ut3_develop.ut.expect('Bad').to_equal('Good');
56+
l_integer_variable := 'a string';
57+
end;
58+
end;]';
59+
3460
end;
3561

3662

3763
procedure report_produces_expected_out is
3864
l_output_data ut3_develop.ut_varchar2_list;
39-
l_output clob;
4065
l_expected varchar2(32767);
4166
begin
4267
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='org']
@@ -63,8 +88,8 @@ create or replace package body test_teamcity_reporter as
6388
<!beforeeach!>
6489
<!erroring test!>
6590
<!aftereach!>
66-
%##teamcity[testStdErr timestamp='%' name='ut3_user.test_reporters.erroring_test' out='Test exception:|nORA-06502: PL/SQL: numeric or value error: character to number conversion error|nORA-06512: at "UT3_USER.TEST_REPORTERS", line %|nORA-06512: at %|n']
67-
%##teamcity[testFailed timestamp='%' details='Test exception:|nORA-06502: PL/SQL: numeric or value error: character to number conversion error|nORA-06512: at "UT3_USER.TEST_REPORTERS", line %|nORA-06512: at %|n' message='Error occured' name='ut3_user.test_reporters.erroring_test']
91+
%##teamcity[testStdErr timestamp='%' name='ut3_user.test_reporters.erroring_test' out='Test exception:|nORA-06502: PL/SQL: %: character to number conversion error|nORA-06512: at "UT3_USER.TEST_REPORTERS", line %|nORA-06512: at %|n']
92+
%##teamcity[testFailed timestamp='%' details='Test exception:|nORA-06502: PL/SQL: %: character to number conversion error|nORA-06512: at "UT3_USER.TEST_REPORTERS", line %|nORA-06512: at %|n' message='Error occured' name='ut3_user.test_reporters.erroring_test']
6893
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_user.test_reporters.erroring_test']
6994
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_user.test_reporters.disabled_test']
7095
%##teamcity[testIgnored timestamp='%' name='ut3_user.test_reporters.disabled_test']
@@ -84,7 +109,6 @@ create or replace package body test_teamcity_reporter as
84109

85110
procedure escape_special_chars is
86111
l_output_data ut3_develop.ut_varchar2_list;
87-
l_output clob;
88112
l_expected varchar2(32767);
89113
begin
90114
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='A suite with |'quote|'']
@@ -103,7 +127,6 @@ create or replace package body test_teamcity_reporter as
103127

104128
procedure trims_long_output is
105129
l_output_data ut3_develop.ut_varchar2_list;
106-
l_output clob;
107130
l_expected varchar2(32767);
108131
begin
109132
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_trims_long_output']
@@ -120,11 +143,54 @@ create or replace package body test_teamcity_reporter as
120143
ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected);
121144
end;
122145

146+
procedure report_multiple_expectations is
147+
l_output_data ut3_develop.ut_varchar2_list;
148+
l_expected varchar2(32767);
149+
begin
150+
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_multiple_failures']
151+
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_user.check_multiple_failures.multi_failure']
152+
%##teamcity[testFailed timestamp='%' details='Actual: 1 (number) was expected to be null' name='ut3_user.check_multiple_failures.multi_failure']
153+
%##teamcity[testFailed timestamp='%' details='Actual: 2 (number) was expected to equal: 1 (number)' name='ut3_user.check_multiple_failures.multi_failure']
154+
%##teamcity[testFailed timestamp='%' details='Actual: |'Bad|' (varchar2) was expected to equal: |'Good|' (varchar2)' name='ut3_user.check_multiple_failures.multi_failure']
155+
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_user.check_multiple_failures.multi_failure']
156+
%##teamcity[testSuiteFinished timestamp='%' name='check_multiple_failures']}';
157+
--act
158+
select *
159+
bulk collect into l_output_data
160+
from table(ut3_develop.ut.run('check_multiple_failures.multi_failure',ut3_develop.ut_teamcity_reporter()));
161+
162+
--assert
163+
ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected);
164+
end;
165+
166+
procedure report_multiple_expect_on_err is
167+
l_output_data ut3_develop.ut_varchar2_list;
168+
l_expected varchar2(32767);
169+
begin
170+
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_multiple_failures']
171+
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_user.check_multiple_failures.multi_failure_on_error']
172+
%##teamcity[testStdErr timestamp='%' name='ut3_user.check_multiple_failures.multi_failure_on_error' out='Test exception:|nORA-06502: PL/SQL: %: character to number conversion error|nORA-06512: at "UT3_USER.CHECK_MULTIPLE_FAILURES", line %|nORA-06512: at %|n']
173+
%##teamcity[testFailed timestamp='%' details='Test exception:|nORA-06502: PL/SQL: %: character to number conversion error|nORA-06512: at "UT3_USER.CHECK_MULTIPLE_FAILURES", line %|nORA-06512: at %|n' message='Error occured' name='ut3_user.check_multiple_failures.multi_failure_on_error']
174+
%##teamcity[testFailed timestamp='%' details='Actual: 1 (number) was expected to be null' name='ut3_user.check_multiple_failures.multi_failure_on_error']
175+
%##teamcity[testFailed timestamp='%' details='Actual: 2 (number) was expected to equal: 1 (number)' name='ut3_user.check_multiple_failures.multi_failure_on_error']
176+
%##teamcity[testFailed timestamp='%' details='Actual: |'Bad|' (varchar2) was expected to equal: |'Good|' (varchar2)' name='ut3_user.check_multiple_failures.multi_failure_on_error']
177+
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_user.check_multiple_failures.multi_failure_on_error']
178+
%##teamcity[testSuiteFinished timestamp='%' name='check_multiple_failures']}';
179+
--act
180+
select *
181+
bulk collect into l_output_data
182+
from table(ut3_develop.ut.run('check_multiple_failures.multi_failure_on_error',ut3_develop.ut_teamcity_reporter()));
183+
184+
--assert
185+
ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected);
186+
end;
187+
123188
procedure remove_test_package is
124189
pragma autonomous_transaction;
125190
begin
126191
execute immediate 'drop package check_escape_special_chars';
127192
execute immediate 'drop package check_trims_long_output';
193+
execute immediate 'drop package check_multiple_failures';
128194
end;
129195

130196
end;

test/ut3_user/reporters/test_teamcity_reporter.pks

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ 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_multiple_expectations;
20+
21+
--%test(Reports failures on multiple expectations)
22+
procedure report_multiple_expect_on_err;
23+
1824
--%afterall
1925
procedure remove_test_package;
2026

0 commit comments

Comments
 (0)