From 3f9ae6352e7f19d30634d73b61965d50d10656fc Mon Sep 17 00:00:00 2001 From: lwasylow Date: Fri, 19 May 2017 13:57:59 +0100 Subject: [PATCH 1/5] Fix to coverage html reported.to allow overwrite default test schema --- source/core/types/ut_run.tpb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/types/ut_run.tpb b/source/core/types/ut_run.tpb index 54b031d0e..efde3ea8c 100644 --- a/source/core/types/ut_run.tpb +++ b/source/core/types/ut_run.tpb @@ -29,7 +29,7 @@ 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(); + l_run_schemes := coalesce(coverage_options.schema_names, l_run_schemes); coverage_options.schema_names := l_run_schemes; if coverage_options.exclude_objects is not null then coverage_options.exclude_objects := From 6bd7b12ea7281ef39d1454afde0c45130e6835d5 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Fri, 19 May 2017 14:22:34 +0100 Subject: [PATCH 2/5] Adding default schema list --- source/core/types/ut_run.tpb | 1 + 1 file changed, 1 insertion(+) diff --git a/source/core/types/ut_run.tpb b/source/core/types/ut_run.tpb index efde3ea8c..7e02b4f73 100644 --- a/source/core/types/ut_run.tpb +++ b/source/core/types/ut_run.tpb @@ -29,6 +29,7 @@ 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(); l_run_schemes := coalesce(coverage_options.schema_names, l_run_schemes); coverage_options.schema_names := l_run_schemes; if coverage_options.exclude_objects is not null then From 94c7645dfe3c1d15e36908e2568f8c4a0314db5a Mon Sep 17 00:00:00 2001 From: lwasylow Date: Tue, 23 May 2017 11:32:32 +0100 Subject: [PATCH 3/5] Changes to html code coverage to includea user override of schema. Added tests --- source/core/types/ut_run.tpb | 11 ++++---- tests/RunAll.cmd | 2 +- tests/RunAll.sql | 5 ++++ tests/helpers/html_coverage_test.pck | 25 +++++++++++++++++++ tests/helpers/test_reporters_1.pkb | 12 +++++++++ tests/helpers/test_reporters_1.pks | 9 +++++++ ...ut_html_reporter.DefaultSchemaCoverage.sql | 19 ++++++++++++++ ...ml_reporter.UserOverrideSchemaCoverage.sql | 20 +++++++++++++++ 8 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 tests/helpers/html_coverage_test.pck create mode 100644 tests/helpers/test_reporters_1.pkb create mode 100644 tests/helpers/test_reporters_1.pks create mode 100644 tests/ut_reporters/ut_html_reporter.DefaultSchemaCoverage.sql create mode 100644 tests/ut_reporters/ut_html_reporter.UserOverrideSchemaCoverage.sql diff --git a/source/core/types/ut_run.tpb b/source/core/types/ut_run.tpb index 7e02b4f73..91b871810 100644 --- a/source/core/types/ut_run.tpb +++ b/source/core/types/ut_run.tpb @@ -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; @@ -29,16 +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(); - l_run_schemes := coalesce(coverage_options.schema_names, l_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; diff --git a/tests/RunAll.cmd b/tests/RunAll.cmd index c0a3eef1c..d19832f93 100644 --- a/tests/RunAll.cmd +++ b/tests/RunAll.cmd @@ -1,7 +1,7 @@ echo off set UT3_OWNER=ut3 set UT3_OWNER_PASSWORD=ut3 -set ORACLE_SID=XE +set ORACLE_SID=BLD872B if not [%1] == [] (set UT3_OWNER=%1) if not [%2] == [] (set UT3_OWNER_PASSWORD=%2) if not [%3] == [] (set ORACLE_SID=%3) diff --git a/tests/RunAll.sql b/tests/RunAll.sql index cad9e3035..7ebb7d21c 100644 --- a/tests/RunAll.sql +++ b/tests/RunAll.sql @@ -25,12 +25,15 @@ create table ut$test_table (val varchar2(1)); @@helpers/utplsql_test_reporter.typ @@helpers/test_reporters.pks @@helpers/test_reporters.pkb +@@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 @@ -129,6 +132,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 diff --git a/tests/helpers/html_coverage_test.pck b/tests/helpers/html_coverage_test.pck new file mode 100644 index 000000000..e5cb4ecc3 --- /dev/null +++ b/tests/helpers/html_coverage_test.pck @@ -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; +/ \ No newline at end of file diff --git a/tests/helpers/test_reporters_1.pkb b/tests/helpers/test_reporters_1.pkb new file mode 100644 index 000000000..3192c78da --- /dev/null +++ b/tests/helpers/test_reporters_1.pkb @@ -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; +/ + diff --git a/tests/helpers/test_reporters_1.pks b/tests/helpers/test_reporters_1.pks new file mode 100644 index 000000000..c30fc43bc --- /dev/null +++ b/tests/helpers/test_reporters_1.pks @@ -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; +/ diff --git a/tests/ut_reporters/ut_html_reporter.DefaultSchemaCoverage.sql b/tests/ut_reporters/ut_html_reporter.DefaultSchemaCoverage.sql new file mode 100644 index 000000000..3cb3748cc --- /dev/null +++ b/tests/ut_reporters/ut_html_reporter.DefaultSchemaCoverage.sql @@ -0,0 +1,19 @@ +DECLARE + l_results ut_varchar2_list; + l_clob CLOB; + l_expected VARCHAR2(32767); +BEGIN + l_expected := '%

UT3.TEST_REPORTERS_1

%'; + 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; +/ \ No newline at end of file diff --git a/tests/ut_reporters/ut_html_reporter.UserOverrideSchemaCoverage.sql b/tests/ut_reporters/ut_html_reporter.UserOverrideSchemaCoverage.sql new file mode 100644 index 000000000..ce792b390 --- /dev/null +++ b/tests/ut_reporters/ut_html_reporter.UserOverrideSchemaCoverage.sql @@ -0,0 +1,20 @@ +DECLARE + l_results ut_varchar2_list; + l_clob CLOB; + l_expected VARCHAR2(32767); +BEGIN + l_expected := '%

UT3_USER.HTML_COVERAGE_TEST

%'; + 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; +/ \ No newline at end of file From ab0fe524f7450bef6c071d0e6cc73d50115aec55 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Tue, 23 May 2017 11:39:39 +0100 Subject: [PATCH 4/5] Changes to html code coverage to includea user override of schema. Added tests --- tests/RunAll.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/RunAll.cmd b/tests/RunAll.cmd index d19832f93..c0a3eef1c 100644 --- a/tests/RunAll.cmd +++ b/tests/RunAll.cmd @@ -1,7 +1,7 @@ echo off set UT3_OWNER=ut3 set UT3_OWNER_PASSWORD=ut3 -set ORACLE_SID=BLD872B +set ORACLE_SID=XE if not [%1] == [] (set UT3_OWNER=%1) if not [%2] == [] (set UT3_OWNER_PASSWORD=%2) if not [%3] == [] (set ORACLE_SID=%3) From ecb9ac9ce70f73639f03df338d9575a4fee19d26 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Tue, 23 May 2017 14:12:27 +0100 Subject: [PATCH 5/5] Adding grant for creating procedure outside ut3_owner user --- .travis/install.sh | 4 ++++ tests/RunAll.sql | 1 + 2 files changed, 5 insertions(+) diff --git a/.travis/install.sh b/.travis/install.sh index bb0f6c14e..909361a5a 100644 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -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 diff --git a/tests/RunAll.sql b/tests/RunAll.sql index 7ebb7d21c..b79a40d42 100644 --- a/tests/RunAll.sql +++ b/tests/RunAll.sql @@ -25,6 +25,7 @@ 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