Skip to content

Commit 44b3abb

Browse files
authored
Merge pull request #84 from utPLSQL/feature/update_filter_coverage_by_expr
Expand documentation and tests for coverage filters.
2 parents 39b61ce + 2abb315 commit 44b3abb

8 files changed

Lines changed: 168 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,27 @@ described in [Coverage](https://www.utplsql.org/utPLSQL/latest/userguide/coverag
198198
| `includeObjectExpr` | Regular expression for the names of objects to include |
199199
| `excludeObjectExpr` | Regular expression for the names of objects to exclude |
200200

201-
The regular expression filters need a utPLSQL version that supports them. See
202-
[Coverage reporting options](https://www.utplsql.org/utPLSQL/latest/userguide/coverage.html#coverage-reporting-options).
201+
The plugin passes these values unchanged to utPLSQL, which defines their exact semantics. See
202+
[Filtering objects in coverage reports](https://www.utplsql.org/utPLSQL/latest/userguide/coverage.html#filtering-objects-in-coverage-reports)
203+
in the utPLSQL documentation. The points that matter most in practice:
204+
205+
* The `*Expr` parameters are regular expressions, matched case-insensitively. They are matched against the schema
206+
name (`*SchemaExpr`) or the object name **without** the schema (`*ObjectExpr`). Use `^` and `$` to anchor them,
207+
otherwise any partial match counts (`APP` also matches `MY_APP_TEST`).
208+
* If `includeSchemaExpr` or `includeObjectExpr` is set, utPLSQL ignores `includeObject`. All exclude parameters are
209+
always applied and can be combined.
210+
* utPLSQL ignores all include/exclude filters when file mappings are in use, that is when the plugin finds files for
211+
`sources` (explicitly configured, or in the default `src/main/plsql` directory). See
212+
[Mapping project files to database objects](#mapping-project-files-to-database-objects). Use the filters when
213+
your project does not provide source files to map.
214+
* Blank values are ignored.
215+
216+
Example: report coverage of all packages in the `APP` schema except those ending in `_TMP`:
217+
218+
```xml
219+
<includeSchemaExpr>^APP$</includeSchemaExpr>
220+
<excludeObjectExpr>_TMP$</excludeObjectExpr>
221+
```
203222

204223
### Mapping project files to database objects
205224

@@ -466,7 +485,10 @@ The plugin's integration tests double as examples, in
466485
| `--ora-stuck-timeout` | `oraStuckTimeout` |
467486
| `-include` | `includeObject` |
468487
| `-exclude` | `excludeObject` |
469-
| not available | `includeSchemaExpr`, `excludeSchemaExpr`, `includeObjectExpr`, `excludeObjectExpr` |
488+
| `-include-schema-expr` | `includeSchemaExpr` |
489+
| `-exclude-schema-expr` | `excludeSchemaExpr` |
490+
| `-include-object-expr` | `includeObjectExpr` |
491+
| `-exclude-object-expr` | `excludeObjectExpr` |
470492
| not available | `skipUtplsqlTests` |
471493
| `--coverage-schemes` | not available |
472494
| `-t`, `--timeout` | not available |

‎src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoIT.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ void include_object_expr(MavenExecutionResult result) {
9898
assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml");
9999
}
100100

101+
@MavenTest
102+
void include_schema_expr(MavenExecutionResult result) {
103+
assertThat(result).isSuccessful();
104+
105+
assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml");
106+
}
107+
108+
@MavenTest
109+
void exclude_schema_expr(MavenExecutionResult result) {
110+
assertThat(result).isSuccessful();
111+
112+
assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml");
113+
}
114+
101115
@MavenTest
102116
@SystemProperty(value = "skipTests", content = "true")
103117
void skip_tests(MavenExecutionResult result) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<coverage version="1">
2+
</coverage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<testExecutions version="1">
2+
<file path="plsql.examples.test_pkg_test_me">
3+
<testCase name="test_fc_input_1" duration="1" ></testCase>
4+
<testCase name="test_fc_input_0" duration="1" ></testCase>
5+
<testCase name="test_fc_input_null" duration="1" ></testCase>
6+
<testCase name="test_pr_test_me_null" duration="1" ></testCase>
7+
<testCase name="test_pr_test_me_not_null" duration="1" ></testCase>
8+
<testCase name="test_pr_test_me_exists" duration="1" ></testCase>
9+
<testCase name="test_pr_test_me_cursor" duration="1" ></testCase>
10+
</file>
11+
</testExecutions>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.utplsql</groupId>
7+
<artifactId>owner-param</artifactId>
8+
<version>1.0.0</version>
9+
<packaging>pom</packaging>
10+
11+
<properties>
12+
<dbUrl>jdbc:oracle:thin:@//localhost:1521/FREEPDB1</dbUrl>
13+
<dbUser>UT3</dbUser>
14+
<dbPass>ut3</dbPass>
15+
</properties>
16+
17+
<build>
18+
<plugins>
19+
<plugin>
20+
<groupId>org.utplsql</groupId>
21+
<artifactId>utplsql-maven-plugin</artifactId>
22+
<version>@project.version@</version>
23+
<executions>
24+
<execution>
25+
<goals>
26+
<goal>test</goal>
27+
</goals>
28+
<configuration>
29+
<ignoreFailure>false</ignoreFailure>
30+
<paths>
31+
<path>TESTS_OWNER</path>
32+
</paths>
33+
<reporters>
34+
<reporter>
35+
<name>UT_COVERAGE_SONAR_REPORTER</name>
36+
<fileOutput>utplsql/coverage-sonar-report.xml</fileOutput>
37+
<consoleOutput>true</consoleOutput>
38+
</reporter>
39+
<reporter>
40+
<name>UT_SONAR_TEST_REPORTER</name>
41+
<fileOutput>utplsql/sonar-test-report.xml</fileOutput>
42+
<consoleOutput>true</consoleOutput>
43+
</reporter>
44+
</reporters>
45+
<excludeSchemaExpr>^app$</excludeSchemaExpr>
46+
</configuration>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
</plugins>
51+
</build>
52+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<coverage version="1"><file path="package body app.pkg_test_me"><lineToCover lineNumber="1" covered="false"/><lineToCover lineNumber="2" covered="false"/><lineToCover lineNumber="3" covered="false"/><lineToCover lineNumber="4" covered="false"/><lineToCover lineNumber="5" covered="false"/><lineToCover lineNumber="6" covered="false"/><lineToCover lineNumber="7" covered="false"/><lineToCover lineNumber="8" covered="false"/><lineToCover lineNumber="9" covered="false"/><lineToCover lineNumber="10" covered="false"/><lineToCover lineNumber="11" covered="false"/><lineToCover lineNumber="12" covered="false"/><lineToCover lineNumber="13" covered="false"/><lineToCover lineNumber="14" covered="false"/><lineToCover lineNumber="15" covered="false"/><lineToCover lineNumber="16" covered="false"/><lineToCover lineNumber="17" covered="false"/><lineToCover lineNumber="18" covered="false"/><lineToCover lineNumber="19" covered="false"/><lineToCover lineNumber="20" covered="false"/><lineToCover lineNumber="21" covered="false"/><lineToCover lineNumber="22" covered="false"/><lineToCover lineNumber="23" covered="false"/><lineToCover lineNumber="24" covered="false"/><lineToCover lineNumber="25" covered="false"/><lineToCover lineNumber="26" covered="false"/></file></coverage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<testExecutions version="1">
2+
<file path="plsql.examples.test_pkg_test_me">
3+
<testCase name="test_fc_input_1" duration="1" ></testCase>
4+
<testCase name="test_fc_input_0" duration="1" ></testCase>
5+
<testCase name="test_fc_input_null" duration="1" ></testCase>
6+
<testCase name="test_pr_test_me_null" duration="1" ></testCase>
7+
<testCase name="test_pr_test_me_not_null" duration="1" ></testCase>
8+
<testCase name="test_pr_test_me_exists" duration="1" ></testCase>
9+
<testCase name="test_pr_test_me_cursor" duration="1" ></testCase>
10+
</file>
11+
</testExecutions>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.utplsql</groupId>
7+
<artifactId>owner-param</artifactId>
8+
<version>1.0.0</version>
9+
<packaging>pom</packaging>
10+
11+
<properties>
12+
<dbUrl>jdbc:oracle:thin:@//localhost:1521/FREEPDB1</dbUrl>
13+
<dbUser>UT3</dbUser>
14+
<dbPass>ut3</dbPass>
15+
</properties>
16+
17+
<build>
18+
<plugins>
19+
<plugin>
20+
<groupId>org.utplsql</groupId>
21+
<artifactId>utplsql-maven-plugin</artifactId>
22+
<version>@project.version@</version>
23+
<executions>
24+
<execution>
25+
<goals>
26+
<goal>test</goal>
27+
</goals>
28+
<configuration>
29+
<ignoreFailure>false</ignoreFailure>
30+
<paths>
31+
<path>TESTS_OWNER</path>
32+
</paths>
33+
<reporters>
34+
<reporter>
35+
<name>UT_COVERAGE_SONAR_REPORTER</name>
36+
<fileOutput>utplsql/coverage-sonar-report.xml</fileOutput>
37+
<consoleOutput>true</consoleOutput>
38+
</reporter>
39+
<reporter>
40+
<name>UT_SONAR_TEST_REPORTER</name>
41+
<fileOutput>utplsql/sonar-test-report.xml</fileOutput>
42+
<consoleOutput>true</consoleOutput>
43+
</reporter>
44+
</reporters>
45+
<includeSchemaExpr>^app$</includeSchemaExpr>
46+
</configuration>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
</plugins>
51+
</build>
52+
</project>

0 commit comments

Comments
 (0)