You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/userguide/coverage.md
+53-20Lines changed: 53 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,18 +32,19 @@ If you have `execute` privilege on the code that is being tested, but do not hav
32
32
If you have `execute` privilege only on the unit tests, but do not have `execute` privilege on the code that is being tested, the code will not be reported by coverage - as if it did not exist in the database.
33
33
If the code that is being tested is compiled as NATIVE, the code coverage will not be reported as well.
34
34
35
-
## Running unit tests with coverage
36
-
Using the code coverage functionality is as easy as using any other [reporter](reporters.md) for the utPLSQL test-run. You just run your tests from your preferred SQL tool and save the reporter results to a file.
37
-
All you need to do is pass the constructor of the reporter to the `ut.run` procedure call.
35
+
## Manually running unit tests with coverage
36
+
Using the code coverage functionality is as easy as using any other [reporter](reporters.md) for the utPLSQL test-run. Run your tests from your preferred SQL tool and save the reporter results to a file.
37
+
All you need to do, is pass the constructor of the reporter to the `ut.run` procedure call.
38
38
39
39
Example:
40
40
```sql
41
+
set serveroutput on
41
42
begin
42
43
ut.run(ut_coverage_html_reporter());
43
44
end;
44
45
/
45
46
```
46
-
The above command executes all unit tests in the **current schema**, gathers information about code coverage and outputs the HTML report as text into DBMS_OUTPUT.
47
+
The above command executes all unit tests in the **current schema**, gathers information about code coverage for all sources in that schema and outputs the HTML report as text into DBMS_OUTPUT.
47
48
The `ut_coverage_html_reporter` will produce an interactive HTML report. You can see a sample of code coverage for the utPLSQL project [here](https://utplsql.github.io/utPLSQL-coverage-html/)
48
49
49
50
The report provides summary information with a list of source code that should be covered.
@@ -79,14 +80,14 @@ There are two distinct ways to gather code coverage:
79
80
- Coverage on project files
80
81
81
82
Those two options are mutually exclusive and cannot be mixed.
82
-
By default, when using one of coverage reporters, coverage is gathered on schema(s).
83
+
By default, when using one of coverage reporters, coverage is gathered on schema(s).
84
+
The database schema(s) containing the tests that were executed during the run will be reported on by coverage reporter.
83
85
84
86
The parameters used to execute tests determine if utPLSQL will be using one approach or the other.
87
+
If parameter `a_source_file_mappings` or `a_source_files` is provided, then coverage is gathered on project files provided, otherwise coverage is gathered on schemas.
85
88
86
-
The database schema(s) containing the tests that were executed during the run will be reported on by coverage reporter.
87
89
88
90
**Note**
89
-
90
91
> Regardless of the options provided, all unit test packages are excluded from the coverage report. Coverage reports provide information only about the **tested** code.
91
92
92
93
The default behavior of coverage reporting can be altered using invocation parameters.
There are multiple parameters that can be used to define the scope of coverage report:
133
134
-`a_source_file_mappings ( ut_file_mappings )` - map of filenames to database objects. It is used for file-based coverage - see below.
134
-
-`a_include_schema_expr ( varchar(4000) )` - string of regex expression of schemas to be included in the coverage report.
135
-
-`a_include_object_expr ( varchar(4000) )` - string of regex expression of objects ( without schema name ) to be included in the coverage report.
136
-
-`a_exclude_schema_expr ( varchar(4000) )` - string of regex expression of schemas to be excluded from the coverage report.
137
-
-`a_exclude_object_expr ( varchar(4000) )` - string of regex expression of objects to be excluded from the coverage report.
135
+
-`a_include_schema_expr ( varchar(4000) )` - string of regex expression of schemas to be included in the coverage report. Case-insensitive.
136
+
-`a_include_object_expr ( varchar(4000) )` - string of regex expression of objects ( without schema name ) to be included in the coverage report. Case-insensitive.
137
+
-`a_exclude_schema_expr ( varchar(4000) )` - string of regex expression of schemas to be excluded from the coverage report. Case-insensitive.
138
+
-`a_exclude_object_expr ( varchar(4000) )` - string of regex expression of objects ( without schema name ) to be excluded from the coverage report. Case-insensitive.
138
139
-`a_coverage_schemes ( ut_varchar2_list )` - List of database schema names to gather coverage on.
139
140
-`a_include_objects ( ut_varchar2_list )` - list of `[object_owner.]object_name` to be included in the coverage report.
140
141
-`a_exclude_objects ( ut_varchar2_list )` - list of `[object_owner.]object_name` to be excluded from the coverage report.
@@ -164,6 +165,7 @@ end;
164
165
```
165
166
Will result in showing coverage for all schemas that match regular expression `^ut3_develop`
166
167
168
+
Example: Limiting coverage by schema regex with parameter `a_include_objects` ignored.
0 commit comments