Skip to content

Commit

Permalink
Fixed issue with context generating a separate tag in sonar test-resu…
Browse files Browse the repository at this point in the history
…lts.
  • Loading branch information
jgebal committed Aug 11, 2018
1 parent f590d77 commit cd742e7
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 24 deletions.
11 changes: 9 additions & 2 deletions source/reporters/ut_sonar_test_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,26 @@ create or replace type body ut_sonar_test_reporter is

procedure print_suite_results(a_suite ut_logical_suite, a_file_mappings ut_file_mappings) is
begin

if a_suite is of(ut_suite) and not a_suite is of(ut_suite_context) then
self.print_text('<file path="'||dbms_xmlgen.convert(map_package_to_file(treat(a_suite as ut_suite), a_file_mappings))||'">');
end if;

for i in 1 .. a_suite.items.count loop
if a_suite.items(i) is of(ut_logical_suite) then
print_suite_results(treat(a_suite.items(i) as ut_logical_suite), a_file_mappings);
end if;
end loop;
if a_suite is of(ut_suite) then
self.print_text('<file path="'||dbms_xmlgen.convert(map_package_to_file(treat(a_suite as ut_suite), a_file_mappings))||'">');

if a_suite is of(ut_suite) then
for i in 1 .. a_suite.items.count loop
if a_suite.items(i) is of(ut_test) then
print_test_results(treat(a_suite.items(i) as ut_test));
end if;
end loop;
end if;

if a_suite is of(ut_suite) and not a_suite is of(ut_suite_context) then
self.print_text('</file>');
end if;
end;
Expand Down
7 changes: 6 additions & 1 deletion test/core/reporters.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ create or replace package body reporters is
execute immediate q'[create or replace package test_reporters
as
--%suite(A suite for testing different outcomes from reporters)
--%suitepath(utplsqlorg.helpers.tests.test.test_reporters)
--%suitepath(org.utplsql.tests.helpers)

--%beforeall
procedure beforeall;

--%beforeeach
procedure beforeeach;

--%context(some_context)
--%displayname(A description of some context)

--%test
--%beforetest(beforetest)
--%aftertest(aftertest)
procedure passing_test;

--%endcontext

procedure beforetest;

procedure aftertest;
Expand Down
1 change: 1 addition & 0 deletions test/core/reporters/test_documentation_reporter.pkb
Original file line number Diff line number Diff line change
@@ -0,0 +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;/
Expand Down
10 changes: 10 additions & 0 deletions test/core/reporters/test_documentation_reporter.pks
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
create or replace package test_documentation_reporter as

--%suite(ut_documentation_reporter)
--%suitepath(utplsql.core.reporters)

--%test(Report produces expected output)
procedure report_produces_expected_out;

end;
/
24 changes: 13 additions & 11 deletions test/core/reporters/test_junit_reporter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -247,32 +247,35 @@ create or replace package body test_junit_reporter as
l_actual clob;
l_expected varchar2(32767):=q'[<?xml version="1.0"?>
<testsuites tests="4" disabled="1" errors="1" failures="1" name="" time="%" >
<testsuite tests="4" id="1" package="utplsqlorg" disabled="1" errors="1" failures="1" name="utplsqlorg" time="%" >
<testsuite tests="4" id="2" package="utplsqlorg.helpers" disabled="1" errors="1" failures="1" name="helpers" time="%" >
<testsuite tests="4" id="3" package="utplsqlorg.helpers.tests" disabled="1" errors="1" failures="1" name="tests" time="%" >
<testsuite tests="4" id="4" package="utplsqlorg.helpers.tests.test" disabled="1" errors="1" failures="1" name="test" time="%" >
<testsuite tests="4" id="5" package="utplsqlorg.helpers.tests.test.test_reporters" disabled="1" errors="1" failures="1" name="test_reporters" time="%" >
<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="%" >
<testcase classname="utplsqlorg.helpers.tests.test.test_reporters.test_reporters" assertions="1" name="passing_test" time="%" >
<testsuite tests="4" id="1" package="org" disabled="1" errors="1" failures="1" name="org" time="%" >
<testsuite tests="4" id="2" package="org.utplsql" disabled="1" errors="1" failures="1" name="utplsql" time="%" >
<testsuite tests="4" id="3" package="org.utplsql.tests" disabled="1" errors="1" failures="1" name="tests" time="%" >
<testsuite tests="4" id="4" package="org.utplsql.tests.helpers" disabled="1" errors="1" failures="1" name="helpers" time="%" >
<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="%" >
<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="%" >
<testcase classname="org.utplsql.tests.helpers.test_reporters.some_context" assertions="1" name="passing_test" time="%" >
<system-out>%
</system-out>
<system-err/>
</testcase>
<testcase classname="utplsqlorg.helpers.tests.test.test_reporters.test_reporters" assertions="1" name="a test with failing assertion" time="%" status="Failure">
<system-out/>
<system-err/>
</testsuite>
<testcase classname="org.utplsql.tests.helpers.test_reporters" assertions="1" name="a test with failing assertion" time="%" status="Failure">
<failure>%Fails as values are different%
</failure>
<system-out>%
</system-out>
<system-err/>
</testcase>
<testcase classname="utplsqlorg.helpers.tests.test.test_reporters.test_reporters" assertions="0" name="a test raising unhandled exception" time="%" status="Error">
<testcase classname="org.utplsql.tests.helpers.test_reporters" assertions="0" name="a test raising unhandled exception" time="%" status="Error">
<error>%ORA-06502:%
</error>
<system-out>%
</system-out>
<system-err/>
</testcase>
<testcase classname="utplsqlorg.helpers.tests.test.test_reporters.test_reporters" assertions="0" name="a disabled test" time="0" status="Disabled">
<testcase classname="org.utplsql.tests.helpers.test_reporters" assertions="0" name="a disabled test" time="0" status="Disabled">
<skipped/>
<system-out/>
<system-err/>
Expand All @@ -285,7 +288,6 @@ create or replace package body test_junit_reporter as
</testsuite>
</testsuite>
</testsuite>
</testsuite>
</testsuites>]';

begin
Expand Down
20 changes: 10 additions & 10 deletions test/core/reporters/test_teamcity_reporter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ create or replace package body test_teamcity_reporter as
l_output clob;
l_expected varchar2(32767);
begin
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg']
%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers']
%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers.tests']
%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers.tests.test']
%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers.tests.test.test_reporters']
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='org']
%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql']
%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql.tests']
%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql.tests.helpers']
%##teamcity[testSuiteStarted timestamp='%' name='A suite for testing different outcomes from reporters']
%##teamcity[testSuiteStarted timestamp='%' name='A description of some context']
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.passing_test']
<!beforeeach!>
<!beforetest!>
<!passing test!>
<!aftertest!>
<!aftereach!>
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.passing_test']
%##teamcity[testSuiteFinished timestamp='%' name='A description of some context']
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.failing_test']
<!beforeeach!>
<!failing test!>
Expand All @@ -34,11 +35,10 @@ create or replace package body test_teamcity_reporter as
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.disabled_test']
%##teamcity[testIgnored timestamp='%' name='ut3_tester.test_reporters.disabled_test']
%##teamcity[testSuiteFinished timestamp='%' name='A suite for testing different outcomes from reporters']
%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers.tests.test.test_reporters']
%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers.tests.test']
%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers.tests']
%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers']
%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg']}';
%##teamcity[testSuiteFinished timestamp='%' name='org.utplsql.tests.helpers']
%##teamcity[testSuiteFinished timestamp='%' name='org.utplsql.tests']
%##teamcity[testSuiteFinished timestamp='%' name='org.utplsql']
%##teamcity[testSuiteFinished timestamp='%' name='org']}';
--act
select *
bulk collect into l_output_data
Expand Down
2 changes: 2 additions & 0 deletions test/install_tests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ set define on
@@install_below_12_2.sql 'core/reporters/test_coverage/test_html_proftab_reporter.pks'
set define off
@@core/reporters/test_tfs_junit_reporter.pks
@@core/reporters/test_documentation_reporter.pks
@@core/reporters/test_sonar_test_reporter.pks
@@core/reporters/test_teamcity_reporter.pks
@@core/expectations.pks
Expand Down Expand Up @@ -93,6 +94,7 @@ set define on
@@install_below_12_2.sql 'core/reporters/test_coverage/test_html_proftab_reporter.pkb'
set define off
@@core/reporters/test_tfs_junit_reporter.pkb
@@core/reporters/test_documentation_reporter.pkb
@@core/reporters/test_sonar_test_reporter.pkb
@@core/reporters/test_teamcity_reporter.pkb
@@core/expectations.pkb
Expand Down

0 comments on commit cd742e7

Please sign in to comment.