diff --git a/README.md b/README.md
index 3413199..deab128 100644
--- a/README.md
+++ b/README.md
@@ -216,13 +216,24 @@ utPLSQL reports coverage per source file instead of per database object. The plu
## Skipping tests
-Set `skipUtplsqlTests` to `true` in the plugin configuration or on the command line:
+The utPLSQL tests are skipped together with other tests by Maven's standard `-DskipTests` or `-Dmaven.test.skip=true`:
+
+```bash
+mvn install -DskipTests
+```
+
+To skip only the utPLSQL tests, set `skipUtplsqlTests` to `true` in the plugin configuration or on the command line:
```bash
mvn install -DskipUtplsqlTests=true
```
-Maven's `-DskipTests` does not skip utPLSQL tests.
+`skipUtplsqlTests` takes precedence over `skipTests` and `maven.test.skip`. To skip other tests but run the utPLSQL
+tests, set it to `false`:
+
+```bash
+mvn install -DskipTests -DskipUtplsqlTests=false
+```
To skip the tests by default and enable them only when needed, set the property in the `pom.xml`:
@@ -298,9 +309,10 @@ All parameters are optional:
false
-
-
- false
+
+
+
+
@@ -427,6 +439,10 @@ The plugin's integration tests double as examples, in
* [`ora_stuck_timeout`](src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout):
`oraStuckTimeout`.
* [`skip`](src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip): `skipUtplsqlTests`.
+* [`skip_tests`](src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip_tests),
+ [`maven_test_skip`](src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/maven_test_skip) and
+ [`skip_tests_overridden_by_skip_utplsql_tests`](src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip_tests_overridden_by_skip_utplsql_tests):
+ skipping with `-DskipTests` and `-Dmaven.test.skip=true`, run with the system properties set in `UtPlsqlMojoIT`.
## Comparison with utPLSQL-cli
diff --git a/src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java b/src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java
index c0ba4be..11830ec 100644
--- a/src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java
+++ b/src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java
@@ -128,8 +128,18 @@ public class UtPlsqlMojo extends AbstractMojo {
@Parameter(defaultValue = "${maven.test.failure.ignore}")
boolean ignoreFailure;
- @Parameter(property = "skipUtplsqlTests", defaultValue = "false")
- boolean skipUtplsqlTests;
+ /**
+ * Skips the utPLSQL tests when true, runs them when false.
+ * When not set, the tests are skipped together with other tests by skipTests or maven.test.skip.
+ */
+ @Parameter(property = "skipUtplsqlTests")
+ Boolean skipUtplsqlTests;
+
+ @Parameter(property = "skipTests", defaultValue = "false")
+ boolean skipTests;
+
+ @Parameter(property = "maven.test.skip", defaultValue = "false")
+ boolean mavenTestSkip;
@Parameter
boolean dbmsOutput;
@@ -141,7 +151,7 @@ public class UtPlsqlMojo extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException {
- if (skipUtplsqlTests) {
+ if (isSkipped()) {
getLog().info("utPLSQLTests are skipped.");
} else {
getLog().debug("Java API Version = " + JavaApiVersionInfo.getVersion());
@@ -231,6 +241,18 @@ public void execute() throws MojoExecutionException {
}
}
+ /**
+ * skipUtplsqlTests takes precedence, so -DskipTests -DskipUtplsqlTests=false skips other tests but runs utPLSQL tests.
+ *
+ * @return true when the utPLSQL tests should not be run
+ */
+ boolean isSkipped() {
+ if (skipUtplsqlTests != null) {
+ return skipUtplsqlTests;
+ }
+ return skipTests || mavenTestSkip;
+ }
+
private Connection createConnection() throws SQLException {
if (isEmpty(url)) {
url = System.getProperty("dbUrl");
diff --git a/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoIT.java b/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoIT.java
index ce2f533..310a22e 100644
--- a/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoIT.java
+++ b/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoIT.java
@@ -3,6 +3,7 @@
import com.soebes.itf.jupiter.extension.MavenGoal;
import com.soebes.itf.jupiter.extension.MavenJupiterExtension;
import com.soebes.itf.jupiter.extension.MavenTest;
+import com.soebes.itf.jupiter.extension.SystemProperty;
import com.soebes.itf.jupiter.maven.MavenExecutionResult;
import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat;
@@ -97,4 +98,29 @@ void include_object_expr(MavenExecutionResult result) {
assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml");
}
+ @MavenTest
+ @SystemProperty(value = "skipTests", content = "true")
+ void skip_tests(MavenExecutionResult result) {
+ assertThat(result).isSuccessful();
+
+ assertThat(result.getMavenLog()).info().contains("utPLSQLTests are skipped.");
+ }
+
+ @MavenTest
+ @SystemProperty(value = "maven.test.skip", content = "true")
+ void maven_test_skip(MavenExecutionResult result) {
+ assertThat(result).isSuccessful();
+
+ assertThat(result.getMavenLog()).info().contains("utPLSQLTests are skipped.");
+ }
+
+ @MavenTest
+ @SystemProperty(value = "skipTests", content = "true")
+ @SystemProperty(value = "skipUtplsqlTests", content = "false")
+ void skip_tests_overridden_by_skip_utplsql_tests(MavenExecutionResult result) {
+ assertThat(result).isSuccessful();
+
+ assertThat(result.getMavenLog()).info().doesNotContain("utPLSQLTests are skipped.");
+ }
+
}
diff --git a/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoTest.java b/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoTest.java
index e0df9e7..63a3ea9 100644
--- a/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoTest.java
+++ b/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoTest.java
@@ -247,6 +247,67 @@ void default_reporter(@InjectMojo(goal = "test", pom = "pom.xml") UtPlsqlMojo ut
@Test
@Basedir(UNIT_TESTS + "skip_utplsql_tests")
void skip_utplsql_tests(@InjectMojo(goal = "test", pom = "pom.xml") UtPlsqlMojo utPlsqlMojo) throws Exception {
+ assertTrue(executeAndGetInfoMessages(utPlsqlMojo).contains("utPLSQLTests are skipped."));
+ }
+
+ /**
+ * Skip Tests
+ *
+ * Given : a pom.xml without skipUtplsqlTests and -DskipTests
+ * When : pom is read
+ * Then : Tests are skipped
+ */
+ @Test
+ @Basedir(UNIT_TESTS + "skip_tests")
+ @MojoParameter(name = "skipTests", value = "true")
+ void skip_tests(@InjectMojo(goal = "test", pom = "pom.xml") UtPlsqlMojo utPlsqlMojo) throws Exception {
+ assertTrue(executeAndGetInfoMessages(utPlsqlMojo).contains("utPLSQLTests are skipped."));
+ }
+
+ /**
+ * Maven Test Skip
+ *
+ * Given : a pom.xml without skipUtplsqlTests and -Dmaven.test.skip
+ * When : pom is read
+ * Then : Tests are skipped
+ */
+ @Test
+ @Basedir(UNIT_TESTS + "skip_tests")
+ @MojoParameter(name = "mavenTestSkip", value = "true")
+ void maven_test_skip(@InjectMojo(goal = "test", pom = "pom.xml") UtPlsqlMojo utPlsqlMojo) throws Exception {
+ assertTrue(executeAndGetInfoMessages(utPlsqlMojo).contains("utPLSQLTests are skipped."));
+ }
+
+ /**
+ * Skip Tests overridden by skipUtplsqlTests
+ *
+ * Given : -DskipTests and -DskipUtplsqlTests=false
+ * When : pom is read
+ * Then : utPLSQL tests are not skipped
+ */
+ @Test
+ @Basedir(UNIT_TESTS + "skip_tests")
+ @MojoParameter(name = "skipTests", value = "true")
+ @MojoParameter(name = "mavenTestSkip", value = "true")
+ @MojoParameter(name = "skipUtplsqlTests", value = "false")
+ void skip_tests_overridden_by_skip_utplsql_tests(@InjectMojo(goal = "test", pom = "pom.xml") UtPlsqlMojo utPlsqlMojo) {
+ assertFalse(utPlsqlMojo.isSkipped());
+ }
+
+ /**
+ * Tests are not skipped by default
+ *
+ * Given : a pom.xml without skipUtplsqlTests, skipTests and maven.test.skip
+ * When : pom is read
+ * Then : utPLSQL tests are not skipped
+ */
+ @Test
+ @Basedir(UNIT_TESTS + "skip_tests")
+ void not_skipped_by_default(@InjectMojo(goal = "test", pom = "pom.xml") UtPlsqlMojo utPlsqlMojo) {
+ assertFalse(utPlsqlMojo.isSkipped());
+ }
+
+ private static List executeAndGetInfoMessages(UtPlsqlMojo utPlsqlMojo) throws Exception {
List infoMessages = new ArrayList<>();
utPlsqlMojo.setLog(new SystemStreamLog() {
@Override
@@ -257,7 +318,7 @@ public void info(CharSequence content) {
utPlsqlMojo.execute();
- assertTrue(infoMessages.contains("utPLSQLTests are skipped."));
+ return infoMessages;
}
/**
diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/maven_test_skip/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/maven_test_skip/pom.xml
new file mode 100644
index 0000000..445f53c
--- /dev/null
+++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/maven_test_skip/pom.xml
@@ -0,0 +1,33 @@
+
+ 4.0.0
+
+ org.utplsql
+ maven_test_skip
+ 1.0.0
+ pom
+
+
+ jdbc:oracle:thin:@//localhost:1521/FREEPDB1
+ UT3
+ ut3
+
+
+
+
+
+ org.utplsql
+ utplsql-maven-plugin
+ @project.version@
+
+
+
+ test
+
+
+
+
+
+
+
diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip_tests/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip_tests/pom.xml
new file mode 100644
index 0000000..fcefd39
--- /dev/null
+++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip_tests/pom.xml
@@ -0,0 +1,33 @@
+
+ 4.0.0
+
+ org.utplsql
+ skip_tests
+ 1.0.0
+ pom
+
+
+ jdbc:oracle:thin:@//localhost:1521/FREEPDB1
+ UT3
+ ut3
+
+
+
+
+
+ org.utplsql
+ utplsql-maven-plugin
+ @project.version@
+
+
+
+ test
+
+
+
+
+
+
+
diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip_tests_overridden_by_skip_utplsql_tests/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip_tests_overridden_by_skip_utplsql_tests/pom.xml
new file mode 100644
index 0000000..32af667
--- /dev/null
+++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip_tests_overridden_by_skip_utplsql_tests/pom.xml
@@ -0,0 +1,33 @@
+
+ 4.0.0
+
+ org.utplsql
+ skip_tests_overridden_by_skip_utplsql_tests
+ 1.0.0
+ pom
+
+
+ jdbc:oracle:thin:@//localhost:1521/FREEPDB1
+ UT3
+ ut3
+
+
+
+
+
+ org.utplsql
+ utplsql-maven-plugin
+ @project.version@
+
+
+
+ test
+
+
+
+
+
+
+
diff --git a/src/test/resources/unit-tests/skip_tests/pom.xml b/src/test/resources/unit-tests/skip_tests/pom.xml
new file mode 100644
index 0000000..f57f56c
--- /dev/null
+++ b/src/test/resources/unit-tests/skip_tests/pom.xml
@@ -0,0 +1,30 @@
+
+ 4.0.0
+
+ org.utplsql
+ utplsql-maven-plugin-test
+ 3.1.0-SNAPSHOT
+ pom
+
+
+
+
+
+
+ org.utplsql
+ utplsql-maven-plugin
+ @project.version@
+
+ test
+
+
+
+ app
+
+
+
+
+
+