Skip to content

Support multiple expectation failures with teamcity reporter #1251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ jobs:
oracle-sid: 'XE'
oracle-version: "gvenzl/oracle-xe:21-slim"
oracle-base: '/opt/oracle'
- id: 7
db_version_name: '23free'
oracle-sid: 'FREEPDB1'
oracle-version: "gvenzl/oracle-free:23-slim"
oracle-base: '/opt/oracle'

services:
html_checker:
Expand Down
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
5 changes: 2 additions & 3 deletions test/ut3_user/reporters.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ as

procedure erroring_test
is
l_variable integer;
l_integer_variable integer;
begin
dbms_output.put_line('<!erroring test!>');
l_variable := 'a string';
ut3_develop.ut.expect(l_variable).to_equal(1);
l_integer_variable := 'a string';
end;

procedure disabled_test
Expand Down
2 changes: 1 addition & 1 deletion test/ut3_user/reporters/test_documentation_reporter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Failures:
%
%
2) erroring_test
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06502: PL/SQL: %: character to number conversion error
ORA-06512: at "UT3_USER.TEST_REPORTERS", line 44%
ORA-06512: at line 6
Finished in % seconds
Expand Down
76 changes: 71 additions & 5 deletions test/ut3_user/reporters/test_teamcity_reporter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,37 @@ 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;

--%test
procedure multi_failure_on_error;
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;
procedure multi_failure_on_error is
l_integer_variable integer;
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');
l_integer_variable := 'a string';
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 All @@ -63,8 +88,8 @@ create or replace package body test_teamcity_reporter as
<!beforeeach!>
<!erroring test!>
<!aftereach!>
%##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']
%##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']
%##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']
%##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']
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_user.test_reporters.erroring_test']
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_user.test_reporters.disabled_test']
%##teamcity[testIgnored timestamp='%' name='ut3_user.test_reporters.disabled_test']
Expand All @@ -84,7 +109,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 +127,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 +143,54 @@ 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_multiple_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.multi_failure',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 report_multiple_expect_on_err 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_on_error']
%##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']
%##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']
%##teamcity[testFailed timestamp='%' details='Actual: 1 (number) was expected to be null' name='ut3_user.check_multiple_failures.multi_failure_on_error']
%##teamcity[testFailed timestamp='%' details='Actual: 2 (number) was expected to equal: 1 (number)' name='ut3_user.check_multiple_failures.multi_failure_on_error']
%##teamcity[testFailed timestamp='%' details='Actual: |'Bad|' (varchar2) was expected to equal: |'Good|' (varchar2)' name='ut3_user.check_multiple_failures.multi_failure_on_error']
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_user.check_multiple_failures.multi_failure_on_error']
%##teamcity[testSuiteFinished timestamp='%' name='check_multiple_failures']}';
--act
select *
bulk collect into l_output_data
from table(ut3_develop.ut.run('check_multiple_failures.multi_failure_on_error',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
6 changes: 6 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,12 @@ 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_multiple_expectations;

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

--%afterall
procedure remove_test_package;

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy