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

Skip to content

Commit 74b4db2

Browse files
authored
Merge pull request #751 from utPLSQL/bugfix/sonar_test_reporter
Fixes to ut_sonar_test_reporter
2 parents 8b509c7 + 97b83fa commit 74b4db2

7 files changed

Lines changed: 57 additions & 24 deletions

File tree

source/reporters/ut_sonar_test_reporter.tpb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,32 @@ create or replace type body ut_sonar_test_reporter is
6969

7070
procedure print_suite_results(a_suite ut_logical_suite, a_file_mappings ut_file_mappings) is
7171
begin
72+
7273
for i in 1 .. a_suite.items.count loop
73-
if a_suite.items(i) is of(ut_logical_suite) then
74+
if a_suite.items(i) is of(ut_logical_suite) and a_suite.items(i) is not of(ut_suite_context) then
7475
print_suite_results(treat(a_suite.items(i) as ut_logical_suite), a_file_mappings);
7576
end if;
7677
end loop;
77-
if a_suite is of(ut_suite) then
78+
79+
if a_suite is of(ut_suite) and a_suite is not of(ut_suite_context) then
7880
self.print_text('<file path="'||dbms_xmlgen.convert(map_package_to_file(treat(a_suite as ut_suite), a_file_mappings))||'">');
81+
end if;
7982

83+
for i in 1 .. a_suite.items.count loop
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);
86+
end if;
87+
end loop;
88+
89+
if a_suite is of(ut_suite) then
8090
for i in 1 .. a_suite.items.count loop
8191
if a_suite.items(i) is of(ut_test) then
8292
print_test_results(treat(a_suite.items(i) as ut_test));
8393
end if;
8494
end loop;
95+
end if;
96+
97+
if a_suite is of(ut_suite) and a_suite is not of(ut_suite_context) then
8598
self.print_text('</file>');
8699
end if;
87100
end;

test/core/reporters.pkb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,24 @@ create or replace package body reporters is
66
execute immediate q'[create or replace package test_reporters
77
as
88
--%suite(A suite for testing different outcomes from reporters)
9-
--%suitepath(utplsqlorg.helpers.tests.test.test_reporters)
9+
--%suitepath(org.utplsql.tests.helpers)
1010

1111
--%beforeall
1212
procedure beforeall;
1313

1414
--%beforeeach
1515
procedure beforeeach;
1616

17+
--%context(some_context)
18+
--%displayname(A description of some context)
19+
1720
--%test
1821
--%beforetest(beforetest)
1922
--%aftertest(aftertest)
2023
procedure passing_test;
2124

25+
--%endcontext
26+
2227
procedure beforetest;
2328

2429
procedure aftertest;

test/core/reporters/test_documentation_reporter.pkb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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: 'number [1] ' (varchar2) was expected to equal: 'number [2] ' (varchar2)% at "UT3_TESTER.TEST_REPORTERS%", line 36 ut3.ut.expect('number [1] ','Fails as values are different').to_equal('number [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;/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
create or replace package test_documentation_reporter as
2+
3+
--%suite(ut_documentation_reporter)
4+
--%suitepath(utplsql.core.reporters)
5+
6+
--%test(Report produces expected output)
7+
procedure report_produces_expected_out;
8+
9+
end;
10+
/

test/core/reporters/test_junit_reporter.pkb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,32 +247,35 @@ create or replace package body test_junit_reporter as
247247
l_actual clob;
248248
l_expected varchar2(32767):=q'[<?xml version="1.0"?>
249249
<testsuites tests="4" disabled="1" errors="1" failures="1" name="" time="%" >
250-
<testsuite tests="4" id="1" package="utplsqlorg" disabled="1" errors="1" failures="1" name="utplsqlorg" time="%" >
251-
<testsuite tests="4" id="2" package="utplsqlorg.helpers" disabled="1" errors="1" failures="1" name="helpers" time="%" >
252-
<testsuite tests="4" id="3" package="utplsqlorg.helpers.tests" disabled="1" errors="1" failures="1" name="tests" time="%" >
253-
<testsuite tests="4" id="4" package="utplsqlorg.helpers.tests.test" disabled="1" errors="1" failures="1" name="test" time="%" >
254-
<testsuite tests="4" id="5" package="utplsqlorg.helpers.tests.test.test_reporters" disabled="1" errors="1" failures="1" name="test_reporters" time="%" >
255-
<testsuite tests="4" id="6" package="utplsqlorg.helpers.tests.test.test_reporters.test_reporters" disabled="1" errors="1" failures="1" name="A suite for testing different outcomes from reporters" time="%" >
256-
<testcase classname="utplsqlorg.helpers.tests.test.test_reporters.test_reporters" assertions="1" name="passing_test" time="%" >
250+
<testsuite tests="4" id="1" package="org" disabled="1" errors="1" failures="1" name="org" time="%" >
251+
<testsuite tests="4" id="2" package="org.utplsql" disabled="1" errors="1" failures="1" name="utplsql" time="%" >
252+
<testsuite tests="4" id="3" package="org.utplsql.tests" disabled="1" errors="1" failures="1" name="tests" time="%" >
253+
<testsuite tests="4" id="4" package="org.utplsql.tests.helpers" disabled="1" errors="1" failures="1" name="helpers" time="%" >
254+
<testsuite tests="4" id="5" package="org.utplsql.tests.helpers.test_reporters" disabled="1" errors="1" failures="1" name="A suite for testing different outcomes from reporters" time="%" >
255+
<testsuite tests="1" id="6" package="org.utplsql.tests.helpers.test_reporters.some_context" disabled="0" errors="0" failures="0" name="A description of some context" time="%" >
256+
<testcase classname="org.utplsql.tests.helpers.test_reporters.some_context" assertions="1" name="passing_test" time="%" >
257257
<system-out>%
258258
</system-out>
259259
<system-err/>
260260
</testcase>
261-
<testcase classname="utplsqlorg.helpers.tests.test.test_reporters.test_reporters" assertions="1" name="a test with failing assertion" time="%" status="Failure">
261+
<system-out/>
262+
<system-err/>
263+
</testsuite>
264+
<testcase classname="org.utplsql.tests.helpers.test_reporters" assertions="1" name="a test with failing assertion" time="%" status="Failure">
262265
<failure>%Fails as values are different%
263266
</failure>
264267
<system-out>%
265268
</system-out>
266269
<system-err/>
267270
</testcase>
268-
<testcase classname="utplsqlorg.helpers.tests.test.test_reporters.test_reporters" assertions="0" name="a test raising unhandled exception" time="%" status="Error">
271+
<testcase classname="org.utplsql.tests.helpers.test_reporters" assertions="0" name="a test raising unhandled exception" time="%" status="Error">
269272
<error>%ORA-06502:%
270273
</error>
271274
<system-out>%
272275
</system-out>
273276
<system-err/>
274277
</testcase>
275-
<testcase classname="utplsqlorg.helpers.tests.test.test_reporters.test_reporters" assertions="0" name="a disabled test" time="0" status="Disabled">
278+
<testcase classname="org.utplsql.tests.helpers.test_reporters" assertions="0" name="a disabled test" time="0" status="Disabled">
276279
<skipped/>
277280
<system-out/>
278281
<system-err/>
@@ -285,7 +288,6 @@ create or replace package body test_junit_reporter as
285288
</testsuite>
286289
</testsuite>
287290
</testsuite>
288-
</testsuite>
289291
</testsuites>]';
290292

291293
begin

test/core/reporters/test_teamcity_reporter.pkb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,20 @@ create or replace package body test_teamcity_reporter as
3939
l_output clob;
4040
l_expected varchar2(32767);
4141
begin
42-
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg']
43-
%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers']
44-
%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers.tests']
45-
%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers.tests.test']
46-
%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers.tests.test.test_reporters']
42+
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='org']
43+
%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql']
44+
%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql.tests']
45+
%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql.tests.helpers']
4746
%##teamcity[testSuiteStarted timestamp='%' name='A suite for testing different outcomes from reporters']
47+
%##teamcity[testSuiteStarted timestamp='%' name='A description of some context']
4848
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.passing_test']
4949
<!beforeeach!>
5050
<!beforetest!>
5151
<!passing test!>
5252
<!aftertest!>
5353
<!aftereach!>
5454
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.passing_test']
55+
%##teamcity[testSuiteFinished timestamp='%' name='A description of some context']
5556
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.failing_test']
5657
<!beforeeach!>
5758
<!failing test!>
@@ -68,11 +69,10 @@ create or replace package body test_teamcity_reporter as
6869
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.disabled_test']
6970
%##teamcity[testIgnored timestamp='%' name='ut3_tester.test_reporters.disabled_test']
7071
%##teamcity[testSuiteFinished timestamp='%' name='A suite for testing different outcomes from reporters']
71-
%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers.tests.test.test_reporters']
72-
%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers.tests.test']
73-
%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers.tests']
74-
%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers']
75-
%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg']}';
72+
%##teamcity[testSuiteFinished timestamp='%' name='org.utplsql.tests.helpers']
73+
%##teamcity[testSuiteFinished timestamp='%' name='org.utplsql.tests']
74+
%##teamcity[testSuiteFinished timestamp='%' name='org.utplsql']
75+
%##teamcity[testSuiteFinished timestamp='%' name='org']}';
7676
--act
7777
select *
7878
bulk collect into l_output_data

test/install_tests.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ set define on
4545
@@install_below_12_2.sql 'core/reporters/test_coverage/test_html_proftab_reporter.pks'
4646
set define off
4747
@@core/reporters/test_tfs_junit_reporter.pks
48+
@@core/reporters/test_documentation_reporter.pks
4849
@@core/reporters/test_sonar_test_reporter.pks
4950
@@core/reporters/test_teamcity_reporter.pks
5051
@@core/expectations.pks
@@ -93,6 +94,7 @@ set define on
9394
@@install_below_12_2.sql 'core/reporters/test_coverage/test_html_proftab_reporter.pkb'
9495
set define off
9596
@@core/reporters/test_tfs_junit_reporter.pkb
97+
@@core/reporters/test_documentation_reporter.pkb
9698
@@core/reporters/test_sonar_test_reporter.pkb
9799
@@core/reporters/test_teamcity_reporter.pkb
98100
@@core/expectations.pkb

0 commit comments

Comments
 (0)