Skip to content

Fix to HTML Coverage #326

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 8 commits into from
May 23, 2017
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
4 changes: 4 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ set verify off
@../source/create_utplsql_owner.sql $UT3_OWNER $UT3_OWNER_PASSWORD $UT3_TABLESPACE
--needed for Mystats script to work
grant select any dictionary to $UT3_OWNER;
--Needed for testing a coverage outside ut3_owner.
grant create any procedure, execute any procedure to $UT3_OWNER;

@../source/create_utplsql_owner.sql $UT3_USER $UT3_USER_PASSWORD $UT3_TABLESPACE

cd ..

--enable plsql debug
Expand Down
10 changes: 5 additions & 5 deletions source/core/types/ut_run.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ create or replace type body ut_run as
self in out nocopy ut_run, a_items ut_suite_items, a_run_paths ut_varchar2_list := null,
a_coverage_options ut_coverage_options := null, a_test_file_mappings ut_file_mappings := null
) return self as result is
l_run_schemes ut_varchar2_list;
l_coverage_schema_names ut_varchar2_list;
begin
self.run_paths := a_run_paths;
self.self_type := $$plsql_unit;
Expand All @@ -29,15 +29,15 @@ create or replace type body ut_run as
self.coverage_options := a_coverage_options;
self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings());
if self.coverage_options is not null then
l_run_schemes := get_run_schemes();
coverage_options.schema_names := l_run_schemes;
l_coverage_schema_names := coalesce(coverage_options.schema_names, get_run_schemes());
coverage_options.schema_names := l_coverage_schema_names;
if coverage_options.exclude_objects is not null then
coverage_options.exclude_objects :=
coverage_options.exclude_objects
multiset union all
ut_suite_manager.get_schema_ut_packages(l_run_schemes);
ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names);
else
coverage_options.exclude_objects := ut_suite_manager.get_schema_ut_packages(l_run_schemes);
coverage_options.exclude_objects := ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names);
end if;
end if;
return;
Expand Down
6 changes: 6 additions & 0 deletions tests/RunAll.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ create table ut$test_table (val varchar2(1));
@@helpers/utplsql_test_reporter.typ
@@helpers/test_reporters.pks
@@helpers/test_reporters.pkb
@@helpers/html_coverage_test.pck
@@helpers/test_reporters_1.pks
@@helpers/test_reporters_1.pkb

--Start coverage in develop mode (coverage for utPLSQL framework)
--Regular coverage excludes the framework
exec ut_coverage.coverage_start_develop();
@@lib/mystats/mystats start


@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.IgnoreWrappedPackageAndDoesNotRaiseException.sql
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationMixedWithWrongBeforeProcedure.sql
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationNotBeforeProcedure.sql
Expand Down Expand Up @@ -129,6 +133,8 @@ exec ut_coverage.coverage_start_develop();
@@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql
@@lib/RunTest.sql ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql
@@lib/RunTest.sql ut_reporters/ut_xunit_reporter.ProducesExpectedOutputs.sql
@@lib/RunTest.sql ut_reporters/ut_html_reporter.UserOverrideSchemaCoverage.sql
@@lib/RunTest.sql ut_reporters/ut_html_reporter.DefaultSchemaCoverage.sql

@@lib/RunTest.sql ut/ut.run.AcceptsCoverageFileList.sql
@@lib/RunTest.sql ut/ut.run.AcceptsCoverageFileListWithSutePaths.sql
Expand Down
25 changes: 25 additions & 0 deletions tests/helpers/html_coverage_test.pck
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CREATE OR REPLACE PACKAGE ut3_user.html_coverage_test IS

-- Author : LUW07
-- Created : 23/05/2017 09:37:29
-- Purpose : Supporting html coverage procedure

-- Public type declarations
PROCEDURE run_if_statment(o_result OUT NUMBER);
END HTML_COVERAGE_TEST;
/
CREATE OR REPLACE PACKAGE BODY ut3_user.html_coverage_test IS

-- Private type declarations
PROCEDURE run_if_statment(o_result OUT NUMBER) IS
l_testedvalue NUMBER := 1;
l_success NUMBER := 0;
BEGIN
IF l_testedvalue = 1 THEN
l_success := 1;
END IF;

o_result := l_success;
END run_if_statment;
END HTML_COVERAGE_TEST;
/
12 changes: 12 additions & 0 deletions tests/helpers/test_reporters_1.pkb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
create or replace package body test_reporters_1
as
procedure diffrentowner_test
is
l_result number;
begin
ut3_user.html_coverage_test.run_if_statment(l_result);
ut.expect(l_result).to_equal(1);
end;
end;
/

9 changes: 9 additions & 0 deletions tests/helpers/test_reporters_1.pks
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
create or replace package test_reporters_1
as
--%suite(A suite for testing html coverage options)

--%test(a test calling package outside schema)
procedure diffrentowner_test;

end;
/
19 changes: 19 additions & 0 deletions tests/ut_reporters/ut_html_reporter.DefaultSchemaCoverage.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
DECLARE
l_results ut_varchar2_list;
l_clob CLOB;
l_expected VARCHAR2(32767);
BEGIN
l_expected := '%<h3>UT3.TEST_REPORTERS_1</h3>%';
SELECT * BULK COLLECT
INTO l_results
FROM TABLE(ut.run('test_reporters_1', ut_coverage_html_reporter()));
l_clob := ut3.ut_utils.table_to_clob(l_results);

IF l_clob LIKE l_expected THEN
:test_result := ut3.ut_utils.tr_success;
ELSE
dbms_output.put_line('Failed to match to default schema');
END IF;

END;
/
20 changes: 20 additions & 0 deletions tests/ut_reporters/ut_html_reporter.UserOverrideSchemaCoverage.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
DECLARE
l_results ut_varchar2_list;
l_clob CLOB;
l_expected VARCHAR2(32767);
BEGIN
l_expected := '%<h3>UT3_USER.HTML_COVERAGE_TEST</h3>%';
SELECT * BULK COLLECT
INTO l_results
FROM TABLE(ut.run('test_reporters_1', ut_coverage_html_reporter(),
a_coverage_schemes => ut_varchar2_list('ut3_user')));
l_clob := ut3.ut_utils.table_to_clob(l_results);

IF l_clob LIKE l_expected THEN
:test_result := ut3.ut_utils.tr_success;
ELSE
dbms_output.put_line('Failed to run coverage outside schema');
END IF;

END;
/