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

Skip to content

Commit 3c5cd62

Browse files
committed
Fixed regression with nested suites reporting for sonar test execution.
Fixed issue with test on documentation reporter on 11g-12.1.
1 parent cd742e7 commit 3c5cd62

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

source/reporters/ut_sonar_test_reporter.tpb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,19 @@ create or replace type body ut_sonar_test_reporter is
7070
procedure print_suite_results(a_suite ut_logical_suite, a_file_mappings ut_file_mappings) is
7171
begin
7272

73-
if a_suite is of(ut_suite) and not a_suite is of(ut_suite_context) then
73+
for i in 1 .. a_suite.items.count loop
74+
if a_suite.items(i) is of(ut_logical_suite) and a_suite.items(i) is not of(ut_suite_context) then
75+
print_suite_results(treat(a_suite.items(i) as ut_logical_suite), a_file_mappings);
76+
end if;
77+
end loop;
78+
79+
if a_suite is of(ut_suite) and a_suite is not of(ut_suite_context) then
7480
self.print_text('<file path="'||dbms_xmlgen.convert(map_package_to_file(treat(a_suite as ut_suite), a_file_mappings))||'">');
7581
end if;
7682

7783
for i in 1 .. a_suite.items.count loop
78-
if a_suite.items(i) is of(ut_logical_suite) then
79-
print_suite_results(treat(a_suite.items(i) as ut_logical_suite), a_file_mappings);
84+
if a_suite.items(i) is of(ut_suite_context) then
85+
print_suite_results(treat(a_suite.items(i) as ut_suite_context), a_file_mappings);
8086
end if;
8187
end loop;
8288

@@ -88,7 +94,7 @@ create or replace type body ut_sonar_test_reporter is
8894
end loop;
8995
end if;
9096

91-
if a_suite is of(ut_suite) and not a_suite is of(ut_suite_context) then
97+
if a_suite is of(ut_suite) and a_suite is not of(ut_suite_context) then
9298
self.print_text('</file>');
9399
end if;
94100
end;

test/core/reporters/test_documentation_reporter.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
create or replace package body test_documentation_reporter as procedure report_produces_expected_out is l_results ut3.ut_varchar2_list; l_actual clob; l_expected varchar2(32767):=q'[%org utplsql tests helpers A suite for testing different outcomes from reporters <!beforeall!> A description of some context passing_test [% sec] <!beforeeach!> <!beforetest!> <!passing test!> <!aftertest!> <!aftereach!> a test with failing assertion [% sec] (FAILED - 1) <!beforeeach!> <!failing test!> <!aftereach!> a test raising unhandled exception [% sec] (FAILED - 2) <!beforeeach!> <!erroring test!> <!aftereach!> a disabled test [0 sec] (DISABLED) <!afterall!>%Failures:% 1) failing_test "Fails as values are different" Actual: 1 (number) was expected to equal: 2 (number)% at "UT3_TESTER.TEST_REPORTERS.FAILING_TEST", line 36 ut3.ut.expect(1,'Fails as values are different').to_equal(2);%% 2) erroring_test ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at "UT3_TESTER.TEST_REPORTERS", line 44 ORA-06512: at "UT3_TESTER.TEST_REPORTERS", line 44 ORA-06512: at line 6Finished in % seconds4 tests, 1 failed, 1 errored, 1 disabled, 0 warning(s)%]'; begin select * bulk collect into l_results from table( ut3.ut.run( 'test_reporters', ut3.ut_documentation_reporter() ) ); l_actual := ut3.ut_utils.table_to_clob(l_results); ut.expect(l_actual).to_be_like(l_expected); end; procedure check_encoding_included is begin reporters.check_xml_encoding_included(ut3.ut_sonar_test_reporter(), 'UTF-8'); end;end;/
1+
create or replace package body test_documentation_reporter as procedure report_produces_expected_out is l_results ut3.ut_varchar2_list; l_actual clob; l_expected varchar2(32767):=q'[%org utplsql tests helpers A suite for testing different outcomes from reporters <!beforeall!> A description of some context passing_test [% sec] <!beforeeach!> <!beforetest!> <!passing test!> <!aftertest!> <!aftereach!> a test with failing assertion [% sec] (FAILED - 1) <!beforeeach!> <!failing test!> <!aftereach!> a test raising unhandled exception [% sec] (FAILED - 2) <!beforeeach!> <!erroring test!> <!aftereach!> a disabled test [0 sec] (DISABLED) <!afterall!>%Failures:% 1) failing_test "Fails as values are different" Actual: 1 (number) was expected to equal: 2 (number)% at "UT3_TESTER.TEST_REPORTERS%", line 36 ut3.ut.expect(1,'Fails as values are different').to_equal(2);%% 2) erroring_test ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at "UT3_TESTER.TEST_REPORTERS", line 44% ORA-06512: at line 6Finished in % seconds4 tests, 1 failed, 1 errored, 1 disabled, 0 warning(s)%]'; begin select * bulk collect into l_results from table( ut3.ut.run( 'test_reporters', ut3.ut_documentation_reporter() ) ); l_actual := ut3.ut_utils.table_to_clob(l_results); ut.expect(l_actual).to_be_like(l_expected); end; procedure check_encoding_included is begin reporters.check_xml_encoding_included(ut3.ut_sonar_test_reporter(), 'UTF-8'); end;end;/

test/install_and_run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ time "$SQLCLI" ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@//${CONNECTION_STR} @install
1313
cd ..
1414

1515
time utPLSQL-cli/bin/utplsql run ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@${CONNECTION_STR} \
16-
-source_path=source -owner=ut3 \
16+
-source_path=source -owner=ut3 -p=test_documentation_reporter \
1717
-test_path=test -c \
1818
-f=ut_documentation_reporter -o=test_results.log -s \
1919
-f=ut_coverage_sonar_reporter -o=coverage.xml \

0 commit comments

Comments
 (0)