Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
287590b
12.2 Stable :
lwasylow Mar 11, 2018
68768f8
12.2 Stable :
lwasylow Mar 13, 2018
76bf869
12.2 Stable :
lwasylow Mar 13, 2018
1f4f5f0
Tests 12.2 Coverage:
lwasylow Mar 14, 2018
90858eb
Added 12.2 coverage
lwasylow Mar 14, 2018
d77cf9a
Test 12.2 coverage
lwasylow Mar 14, 2018
4f83357
Added 12.2 Coverage
lwasylow Mar 14, 2018
ac40332
Added 12.2 Coverage
lwasylow Mar 14, 2018
5f74db9
Merge pull request #602 from lwasylow/12coveragestab2
lwasylow Mar 14, 2018
9d7f16c
Added conditional install of tests for 12.2 only - when block coverag…
jgebal Mar 15, 2018
20541b5
Refactoring coverage:
lwasylow Mar 18, 2018
ab7eb93
Coverage Refactoring:
lwasylow Mar 23, 2018
8dbb1a1
Merge pull request #614 from lwasylow/feature/12cblockcoverage
lwasylow Mar 25, 2018
e0b220d
Merge branch 'develop' into feature/12cblockcoverage
lwasylow Mar 25, 2018
2560f5b
Revert "Feature/12cblockcoverage"
lwasylow Mar 25, 2018
6fe32c5
Merge pull request #615 from utPLSQL/revert-614-feature/12cblockcoverage
lwasylow Mar 25, 2018
8235848
Refactor Coverage:
lwasylow Mar 25, 2018
78fdab5
Refactor Coverage:
lwasylow Mar 25, 2018
3a19341
Merge branch 'feature/12cblockcoverage' of github.com:lwasylow/utPLSQ…
lwasylow Mar 25, 2018
466e126
Update test local
lwasylow Mar 25, 2018
e968f76
Merge pull request #616 from lwasylow/feature/12cblockcoverage
lwasylow Mar 25, 2018
0f1d789
12.2 coverage
lwasylow Apr 3, 2018
faab0fe
Merge pull request #625 from lwasylow/feature/12cblockcoverage
lwasylow Apr 3, 2018
35e5e13
12.2 coverage
lwasylow Apr 3, 2018
1289e99
Merge branch 'feature/12cblockcoverage' of github.com:lwasylow/utPLSQ…
lwasylow Apr 3, 2018
d3ce10c
Merge pull request #626 from lwasylow/feature/12cblockcoverage
lwasylow Apr 3, 2018
c0ca9d3
Fixing error in package name
lwasylow Apr 3, 2018
f151a6e
Update test
lwasylow Apr 4, 2018
28f7653
Statement Coverage First Commit
lwasylow Apr 7, 2018
1f51049
Merge branch 'develop' of https://github.com/utPLSQL/utPLSQL into fea…
lwasylow Apr 7, 2018
9c87b06
Merge branch 'develop' of github.com:utPLSQL/utPLSQL into feature/12c…
lwasylow Apr 7, 2018
d8b8e87
Updated coverage with statement level information
lwasylow Apr 7, 2018
49b1b84
Move get_cov_sql function into common package to remove code duplication
lwasylow Apr 8, 2018
ab7eb24
Refactor Coverage to now enrich profile for partially covered lines u…
lwasylow Apr 8, 2018
36279fa
Update tests and fixed typo in original coverage reporter
lwasylow Apr 10, 2018
661ef74
Merge branch 'feature/12cblockcoverage' of https://github.com/utPLSQL…
lwasylow Apr 10, 2018
57f7a4f
Updated coverage
lwasylow Apr 11, 2018
3a2ff00
Merge branch 'develop' of https://github.com/utPLSQL/utPLSQL into fea…
lwasylow Apr 11, 2018
e6c2be2
Merge pull request #640 from lwasylow/feature/12cov_extended
lwasylow Apr 11, 2018
c9cb004
Fixes to conditional compilation
lwasylow Apr 11, 2018
a862b95
Fixes to new asso array during mock coverage id.
lwasylow Apr 11, 2018
57ee184
Merge pull request #641 from lwasylow/feature/12cblockcoverage
lwasylow Apr 11, 2018
4561795
Update test
lwasylow Apr 11, 2018
0556fbe
Update test
lwasylow Apr 11, 2018
b91e51d
Merge branch 'feature/12cblockcoverage' of github.com:utPLSQL/utPLSQL…
lwasylow Apr 11, 2018
d19f941
Update test/core/reporters/test_extended_coverage.pkb
lwasylow Apr 11, 2018
e2e1437
Updated html reporter to show a information about the partially cover…
lwasylow Apr 11, 2018
a112e36
Added support for block coverage in sonar and cobertura reporters.
jgebal Apr 14, 2018
f0e2653
Clean-up and removal of unnecessary reporters
lwasylow Apr 15, 2018
4458dff
Unify reporters
lwasylow Apr 15, 2018
2027421
Update test
lwasylow Apr 15, 2018
924eb9b
Update issue with part covered being zero.
lwasylow Apr 15, 2018
a111c6d
Update for test with timestamp
lwasylow Apr 15, 2018
2d6c7d3
Merge branch 'develop' into feature/12cblockcoverage
lwasylow Apr 16, 2018
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
18 changes: 17 additions & 1 deletion docs/userguide/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If you have `execute` privilege on the code that are tested, but do not have `cr
If you have `execute` privilege only on the unit tests, but do not have `execute` privilege on the code that is tested, the code will not be reported by coverage - as if it did not exist in the database.
If the code that is testes is complied as NATIVE, the code coverage will not be reported as well.

## Running unite tests with coverage
## Running unit tests with coverage
Using code coverage functionality is as easy as using any other [reporter](reporters.md) for utPLSQL project. All you need to do is run your tests from your preferred SQL tool and save the outcomes of reporter to a file.
All you need to do, is pass the constructor of the reporter to your `ut.run`

Expand All @@ -40,6 +40,8 @@ begin
end;
/
```


Executes all unit tests in current schema, gather information about code coverage and output the html text into DBMS_OUTPUT.
The `ut_coverage_html_reporter` will produce a interactive HTML report. You may see a sample of code coverage for utPLSQL project [here](https://utplsql.github.io/utPLSQL-coverage-html/)

Expand All @@ -52,6 +54,20 @@ The report allow to navigate to every source and inspect line by line coverage.
![Coverage Details page](../images/coverage_html_details.png)


#### Oracle 12.2 block coverage.
In Oracle 12.2 new functionality was released which supports native [block coverage](https://docs.oracle.com/en/database/oracle/oracle-database/12.2/arpls/DBMS_PLSQL_CODE_COVERAGE.html#GUID-55A9E502-9EC2-4118-B292-DC79E6DC465E).
This has been enabled in utPLSQL code coverage as a separate option. It can be invoked by passing a argument a_coverage_type with value 'block'. By default profiler option is enabled ('proftab').

Example:
```sql
begin
ut.run(ut_coverage_html_reporter(),a_coverage_type => 'block');
end;
/
```

In this mode html reporter will show additionally number of lines that been partially covered and highlight them in orange. Number of blocks in code, blocks covered and missed.

## Coverage reporting options
By default the database schema/schemes containing the tests that were executed during the run, are fully reported by coverage reporter.
All valid unit tests are excluded from the report regardless if they were invoked or not. This way the coverage report is not affected by presence of tests and contains only the tested code.
Expand Down
56 changes: 28 additions & 28 deletions source/api/ut.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,29 @@ create or replace package body ut is

procedure run_autonomous(
a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer,
a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings, a_test_file_mappings ut_file_mappings,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_file_mappings ut_file_mappings, a_test_file_mappings ut_file_mappings,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new parameter should be added as last to avoid breaking changes to API.

a_include_objects ut_varchar2_list, a_exclude_objects ut_varchar2_list
) is
pragma autonomous_transaction;
begin
ut_runner.run(
a_paths, ut_reporters(coalesce(a_reporter,ut_documentation_reporter())),
ut_utils.int_to_boolean(a_color_console), a_coverage_schemes,
ut_utils.int_to_boolean(a_color_console), a_coverage_schemes,a_coverage_type,
a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects
);
rollback;
end;

procedure run_autonomous(
a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer,
a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

a_include_objects ut_varchar2_list, a_exclude_objects ut_varchar2_list
) is
pragma autonomous_transaction;
begin
ut_runner.run(
a_paths, ut_reporters(coalesce(a_reporter,ut_documentation_reporter())),
ut_utils.int_to_boolean(a_color_console), a_coverage_schemes,
ut_utils.int_to_boolean(a_color_console), a_coverage_schemes,a_coverage_type,
ut_file_mapper.build_file_mappings(a_source_files),
ut_file_mapper.build_file_mappings(a_test_files),
a_include_objects, a_exclude_objects
Expand All @@ -138,7 +138,7 @@ create or replace package body ut is

function run(
a_reporter ut_reporter_base := null, a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) return ut_varchar2_rows pipelined is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
Expand All @@ -148,7 +148,7 @@ create or replace package body ut is
begin
run_autonomous(
l_paths, l_reporter, a_color_console,
a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects
a_coverage_schemes,a_coverage_type, a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects
);
if l_reporter is of (ut_output_reporter_base) then
l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
Expand All @@ -165,7 +165,7 @@ create or replace package body ut is

function run(
a_reporter ut_reporter_base := null, a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) return ut_varchar2_rows pipelined is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
Expand All @@ -174,7 +174,7 @@ create or replace package body ut is
l_line varchar2(4000);
begin
run_autonomous(
l_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
l_paths, l_reporter, a_color_console, a_coverage_schemes,a_coverage_type, a_source_files, a_test_files,
a_include_objects, a_exclude_objects
);
if l_reporter is of (ut_output_reporter_base) then
Expand All @@ -192,15 +192,15 @@ create or replace package body ut is

function run(
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) return ut_varchar2_rows pipelined is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
l_lines sys_refcursor;
l_line varchar2(4000);
begin
run_autonomous(
a_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
a_paths, l_reporter, a_color_console, a_coverage_schemes,a_coverage_type, a_source_file_mappings, a_test_file_mappings,
a_include_objects, a_exclude_objects
);
if l_reporter is of (ut_output_reporter_base) then
Expand All @@ -218,15 +218,15 @@ create or replace package body ut is

function run(
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) return ut_varchar2_rows pipelined is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
l_lines sys_refcursor;
l_line varchar2(4000);
begin
run_autonomous(
a_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
a_paths, l_reporter, a_color_console, a_coverage_schemes,a_coverage_type, a_source_files, a_test_files,
a_include_objects, a_exclude_objects
);
if l_reporter is of (ut_output_reporter_base) then
Expand All @@ -244,7 +244,7 @@ create or replace package body ut is

function run(
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) return ut_varchar2_rows pipelined is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
Expand All @@ -253,7 +253,7 @@ create or replace package body ut is
l_line varchar2(4000);
begin
run_autonomous(
l_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
l_paths, l_reporter, a_color_console, a_coverage_schemes,a_coverage_type, a_source_file_mappings, a_test_file_mappings,
a_include_objects, a_exclude_objects
);
if l_reporter is of (ut_output_reporter_base) then
Expand All @@ -271,7 +271,7 @@ create or replace package body ut is

function run(
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) return ut_varchar2_rows pipelined is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
Expand All @@ -280,7 +280,7 @@ create or replace package body ut is
l_line varchar2(4000);
begin
run_autonomous(
l_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
l_paths, l_reporter, a_color_console, a_coverage_schemes,a_coverage_type, a_source_files, a_test_files,
a_include_objects, a_exclude_objects
);
if l_reporter is of (ut_output_reporter_base) then
Expand All @@ -298,13 +298,13 @@ create or replace package body ut is

procedure run(
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
begin
run_autonomous(
a_paths, l_reporter, ut_utils.boolean_to_int(a_color_console), a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
a_paths, l_reporter, ut_utils.boolean_to_int(a_color_console), a_coverage_schemes,a_coverage_type, a_source_file_mappings, a_test_file_mappings,
a_include_objects, a_exclude_objects
);
if l_reporter is of (ut_output_reporter_base) then
Expand All @@ -315,13 +315,13 @@ create or replace package body ut is

procedure run(
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
begin
run_autonomous(
a_paths, l_reporter, ut_utils.boolean_to_int(a_color_console), a_coverage_schemes, a_source_files, a_test_files,
a_paths, l_reporter, ut_utils.boolean_to_int(a_color_console), a_coverage_schemes,a_coverage_type, a_source_files, a_test_files,
a_include_objects, a_exclude_objects
);
if l_reporter is of (ut_output_reporter_base) then
Expand All @@ -332,50 +332,50 @@ create or replace package body ut is

procedure run(
a_reporter ut_reporter_base := null, a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) is
begin
ut.run(
ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console,
a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects
a_coverage_schemes,a_coverage_type, a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects
);
end;

procedure run(
a_reporter ut_reporter_base := null, a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) is
begin
ut.run(
ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console,
a_coverage_schemes, a_source_files, a_test_files, a_include_objects, a_exclude_objects
a_coverage_schemes,a_coverage_type, a_source_files, a_test_files, a_include_objects, a_exclude_objects
);
end;

procedure run(
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) is
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
begin
ut.run(
l_paths, a_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
l_paths, a_reporter, a_color_console, a_coverage_schemes,a_coverage_type, a_source_file_mappings, a_test_file_mappings,
a_include_objects, a_exclude_objects
);
end;

procedure run(
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
) is
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
begin
ut.run(
l_paths, a_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
l_paths, a_reporter, a_color_console, a_coverage_schemes,a_coverage_type, a_source_files, a_test_files,
a_include_objects, a_exclude_objects
);
end;
Expand Down
Loading