Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improvements to teamcity reporter (used by DataGrip and IntelliJ - Je…
…tBrains IDEs)

The reporter will now report all errors and all failed expectations.
The test description will be used instead of test name.
  • Loading branch information
jgebal committed Apr 12, 2023
commit e6a6a4cbf108b44932fb114c07e2d18f62ee687f
33 changes: 19 additions & 14 deletions source/reporters/ut_teamcity_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,28 @@ create or replace type body ut_teamcity_reporter is
ut_teamcity_reporter_helper.test_failed(
a_test_name => l_test_full_name,
a_msg => 'Error occured',
a_details =>
trim(l_std_err_msg)
|| case when a_test.failed_expectations is not null
and a_test.failed_expectations.count>0
then a_test.failed_expectations(1).message end
a_details => trim(l_std_err_msg)
)
);
for i in 1 .. a_test.failed_expectations.count loop
ut_utils.append_to_list(
l_results,
ut_teamcity_reporter_helper.test_failed(
a_test_name => l_test_full_name,
a_msg => a_test.failed_expectations(i).description,
a_details => a_test.failed_expectations(i).message )
);
end loop;
elsif a_test.failed_expectations is not null and a_test.failed_expectations.count > 0 then
-- Teamcity supports only a single failure message

ut_utils.append_to_list(
l_results,
ut_teamcity_reporter_helper.test_failed(
a_test_name => l_test_full_name,
a_msg => a_test.failed_expectations(a_test.failed_expectations.first).description,
a_details => a_test.failed_expectations(a_test.failed_expectations.first).message )
);
for i in 1 .. a_test.failed_expectations.count loop
ut_utils.append_to_list(
l_results,
ut_teamcity_reporter_helper.test_failed(
a_test_name => l_test_full_name,
a_msg => a_test.failed_expectations(i).description,
a_details => a_test.failed_expectations(i).message )
);
end loop;
elsif a_test.result = ut_utils.gc_failure then
ut_utils.append_to_list(
l_results,
Expand Down
2 changes: 0 additions & 2 deletions source/reporters/ut_teamcity_reporter_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ create or replace package body ut_teamcity_reporter_helper is
'true'
when false then
'false'
else
null
end;
l_props('flowId') := a_flow_id;
return message('testStarted', l_props);
Expand Down
39 changes: 36 additions & 3 deletions test/ut3_user/reporters/test_teamcity_reporter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,26 @@ create or replace package body test_teamcity_reporter as
end;
end;]';

execute immediate q'[create or replace package check_multiple_failures is
--%suite

--%test
procedure multi_failure;
end;]';
execute immediate q'[create or replace package body check_multiple_failures is
procedure multi_failure is
begin
ut3_develop.ut.expect(1).to_be_null;
ut3_develop.ut.expect(2).to_equal(1);
ut3_develop.ut.expect('Bad').to_equal('Good');
end;
end;]';

end;


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

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

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

procedure report_mutiple_expectations is
l_output_data ut3_develop.ut_varchar2_list;
l_expected varchar2(32767);
begin
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_multiple_failures']
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_user.check_multiple_failures.multi_failure']
%##teamcity[testFailed timestamp='%' details='Actual: 1 (number) was expected to be null' name='ut3_user.check_multiple_failures.multi_failure']
%##teamcity[testFailed timestamp='%' details='Actual: 2 (number) was expected to equal: 1 (number)' name='ut3_user.check_multiple_failures.multi_failure']
%##teamcity[testFailed timestamp='%' details='Actual: |'Bad|' (varchar2) was expected to equal: |'Good|' (varchar2)' name='ut3_user.check_multiple_failures.multi_failure']
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_user.check_multiple_failures.multi_failure']
%##teamcity[testSuiteFinished timestamp='%' name='check_multiple_failures']}';
--act
select *
bulk collect into l_output_data
from table(ut3_develop.ut.run('check_multiple_failures',ut3_develop.ut_teamcity_reporter()));

--assert
ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected);
end;

procedure remove_test_package is
pragma autonomous_transaction;
begin
execute immediate 'drop package check_escape_special_chars';
execute immediate 'drop package check_trims_long_output';
execute immediate 'drop package check_multiple_failures';
end;

end;
Expand Down
3 changes: 3 additions & 0 deletions test/ut3_user/reporters/test_teamcity_reporter.pks
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ create or replace package test_teamcity_reporter as
--%test(Trims output so it fits into 4000 chars)
procedure trims_long_output;

--%test(Reports failures on multiple expectations)
procedure report_mutiple_expectations;

--%afterall
procedure remove_test_package;

Expand Down