Skip to content

Commit 94c7645

Browse files
committed
Changes to html code coverage to includea user override of schema. Added tests
1 parent 6bd7b12 commit 94c7645

File tree

8 files changed

+96
-7
lines changed

8 files changed

+96
-7
lines changed

source/core/types/ut_run.tpb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ create or replace type body ut_run as
2020
self in out nocopy ut_run, a_items ut_suite_items, a_run_paths ut_varchar2_list := null,
2121
a_coverage_options ut_coverage_options := null, a_test_file_mappings ut_file_mappings := null
2222
) return self as result is
23-
l_run_schemes ut_varchar2_list;
23+
l_coverage_schema_names ut_varchar2_list;
2424
begin
2525
self.run_paths := a_run_paths;
2626
self.self_type := $$plsql_unit;
@@ -29,16 +29,15 @@ create or replace type body ut_run as
2929
self.coverage_options := a_coverage_options;
3030
self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings());
3131
if self.coverage_options is not null then
32-
l_run_schemes := get_run_schemes();
33-
l_run_schemes := coalesce(coverage_options.schema_names, l_run_schemes);
34-
coverage_options.schema_names := l_run_schemes;
32+
l_coverage_schema_names := coalesce(coverage_options.schema_names, get_run_schemes());
33+
coverage_options.schema_names := l_coverage_schema_names;
3534
if coverage_options.exclude_objects is not null then
3635
coverage_options.exclude_objects :=
3736
coverage_options.exclude_objects
3837
multiset union all
39-
ut_suite_manager.get_schema_ut_packages(l_run_schemes);
38+
ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names);
4039
else
41-
coverage_options.exclude_objects := ut_suite_manager.get_schema_ut_packages(l_run_schemes);
40+
coverage_options.exclude_objects := ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names);
4241
end if;
4342
end if;
4443
return;

tests/RunAll.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
echo off
22
set UT3_OWNER=ut3
33
set UT3_OWNER_PASSWORD=ut3
4-
set ORACLE_SID=XE
4+
set ORACLE_SID=BLD872B
55
if not [%1] == [] (set UT3_OWNER=%1)
66
if not [%2] == [] (set UT3_OWNER_PASSWORD=%2)
77
if not [%3] == [] (set ORACLE_SID=%3)

tests/RunAll.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ create table ut$test_table (val varchar2(1));
2525
@@helpers/utplsql_test_reporter.typ
2626
@@helpers/test_reporters.pks
2727
@@helpers/test_reporters.pkb
28+
@@helpers/test_reporters_1.pks
29+
@@helpers/test_reporters_1.pkb
2830

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

36+
3437
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.IgnoreWrappedPackageAndDoesNotRaiseException.sql
3538
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationMixedWithWrongBeforeProcedure.sql
3639
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationNotBeforeProcedure.sql
@@ -129,6 +132,8 @@ exec ut_coverage.coverage_start_develop();
129132
@@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql
130133
@@lib/RunTest.sql ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql
131134
@@lib/RunTest.sql ut_reporters/ut_xunit_reporter.ProducesExpectedOutputs.sql
135+
@@lib/RunTest.sql ut_reporters/ut_html_reporter.UserOverrideSchemaCoverage.sql
136+
@@lib/RunTest.sql ut_reporters/ut_html_reporter.DefaultSchemaCoverage.sql
132137

133138
@@lib/RunTest.sql ut/ut.run.AcceptsCoverageFileList.sql
134139
@@lib/RunTest.sql ut/ut.run.AcceptsCoverageFileListWithSutePaths.sql

tests/helpers/html_coverage_test.pck

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
CREATE OR REPLACE PACKAGE ut3_user.html_coverage_test IS
2+
3+
-- Author : LUW07
4+
-- Created : 23/05/2017 09:37:29
5+
-- Purpose : Supporting html coverage procedure
6+
7+
-- Public type declarations
8+
PROCEDURE run_if_statment(o_result OUT NUMBER);
9+
END HTML_COVERAGE_TEST;
10+
/
11+
CREATE OR REPLACE PACKAGE BODY ut3_user.html_coverage_test IS
12+
13+
-- Private type declarations
14+
PROCEDURE run_if_statment(o_result OUT NUMBER) IS
15+
l_testedvalue NUMBER := 1;
16+
l_success NUMBER := 0;
17+
BEGIN
18+
IF l_testedvalue = 1 THEN
19+
l_success := 1;
20+
END IF;
21+
22+
o_result := l_success;
23+
END run_if_statment;
24+
END HTML_COVERAGE_TEST;
25+
/

tests/helpers/test_reporters_1.pkb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
create or replace package body test_reporters_1
2+
as
3+
procedure diffrentowner_test
4+
is
5+
l_result number;
6+
begin
7+
ut3_user.html_coverage_test.run_if_statment(l_result);
8+
ut.expect(l_result).to_equal(1);
9+
end;
10+
end;
11+
/
12+

tests/helpers/test_reporters_1.pks

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
create or replace package test_reporters_1
2+
as
3+
--%suite(A suite for testing html coverage options)
4+
5+
--%test(a test calling package outside schema)
6+
procedure diffrentowner_test;
7+
8+
end;
9+
/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
DECLARE
2+
l_results ut_varchar2_list;
3+
l_clob CLOB;
4+
l_expected VARCHAR2(32767);
5+
BEGIN
6+
l_expected := '%<h3>UT3.TEST_REPORTERS_1</h3>%';
7+
SELECT * BULK COLLECT
8+
INTO l_results
9+
FROM TABLE(ut.run('test_reporters_1', ut_coverage_html_reporter()));
10+
l_clob := ut3.ut_utils.table_to_clob(l_results);
11+
12+
IF l_clob LIKE l_expected THEN
13+
:test_result := ut3.ut_utils.tr_success;
14+
ELSE
15+
dbms_output.put_line('Failed to match to default schema');
16+
END IF;
17+
18+
END;
19+
/
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
DECLARE
2+
l_results ut_varchar2_list;
3+
l_clob CLOB;
4+
l_expected VARCHAR2(32767);
5+
BEGIN
6+
l_expected := '%<h3>UT3_USER.HTML_COVERAGE_TEST</h3>%';
7+
SELECT * BULK COLLECT
8+
INTO l_results
9+
FROM TABLE(ut.run('test_reporters_1', ut_coverage_html_reporter(),
10+
a_coverage_schemes => ut_varchar2_list('ut3_user')));
11+
l_clob := ut3.ut_utils.table_to_clob(l_results);
12+
13+
IF l_clob LIKE l_expected THEN
14+
:test_result := ut3.ut_utils.tr_success;
15+
ELSE
16+
dbms_output.put_line('Failed to run coverage outside schema');
17+
END IF;
18+
19+
END;
20+
/

0 commit comments

Comments
 (0)