You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2020/05/29 22:32:15 UTC

[maven-surefire] branch SUREFIRE-1733 updated: documentation

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch SUREFIRE-1733
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/SUREFIRE-1733 by this push:
     new 3c96766  documentation
3c96766 is described below

commit 3c96766de3e609162835a17d2b75940b893c02f5
Author: tibordigana <ti...@apache.org>
AuthorDate: Sat May 30 00:32:06 2020 +0200

    documentation
---
 .../src/site/apt/examples/jpms.apt.vm              | 205 +++++++++++++++++++++
 maven-surefire-plugin/src/site/site.xml            |   1 +
 .../com.foo.impl/src/test/java/module-info.java    |   1 +
 3 files changed, 207 insertions(+)

diff --git a/maven-surefire-plugin/src/site/apt/examples/jpms.apt.vm b/maven-surefire-plugin/src/site/apt/examples/jpms.apt.vm
new file mode 100644
index 0000000..5168d12
--- /dev/null
+++ b/maven-surefire-plugin/src/site/apt/examples/jpms.apt.vm
@@ -0,0 +1,205 @@
+ ------
+ Java Modularity (JPMS) in Tests
+ ------
+ dev@maven.apache.org
+ ------
+ 2020-05-29
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements.  See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership.  The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License.  You may obtain a copy of the License at
+ ~~
+ ~~   http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied.  See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Using Java Modularity (JPMS) in Tests
+
+* Examples using TestNG
+
+  The Surefire project provides the integration tests with
+  {{{https://github.com/apache/maven-surefire/tree/master/surefire-its/src/test/resources/surefire-1733-testng}TestNG}}
+  demonstrating the Java Modularity (JPMS).
+
+  The JDK version must be 9 or higher. The POM contains the dependency <<<org.testng:testng:7.1.0>>> which is
+  an automatic module. It activates the internal provider <<<surefire-testng>>> in the plugin. The frameworks with
+  assertions API are used, i.e. <<<org.hamcrest:hamcrest:7.1.0>>> (automatic module)
+  and <<<org.assertj:assertj-core:3.16.1>>> (named module).
+
++---+
+<properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.release>${java.specification.version}</maven.compiler.release>
+</properties>
+
+<dependencies>
+    <dependency>
+        <groupId>org.testng</groupId>
+        <artifactId>testng</artifactId>
+        <version>7.1.0</version>
+        <scope>test</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.hamcrest</groupId>
+        <artifactId>hamcrest</artifactId>
+        <version>2.2</version>
+        <scope>test</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.assertj</groupId>
+        <artifactId>assertj-core</artifactId>
+        <version>3.16.1</version>
+        <scope>test</scope>
+    </dependency>
+</dependencies>
++---+
+
+  The most important parts are the module descriptors. This is the module descriptor located in <<<src/main/java>>>:
+
++---+
+module main
+{
+    exports main;
+}
++---+
+
+  This is the module descriptor in <<<src/test/java>>>:
+
++---+
+module test
+{
+    requires main;
+    requires org.testng;
+    requires org.hamcrest;
+    requires org.assertj.core;
+    exports test to org.testng;
+}
++---+
+
+* Examples using JUnit4
+
+  The Surefire project provides the integration tests with
+  {{{https://github.com/apache/maven-surefire/tree/master/surefire-its/src/test/resources/surefire-1733-junit4}JUnit4}}
+  demonstrating the Java Modularity (JPMS).
+
+  The JDK version must be 9 or higher. The POM contains the dependency <<<junit:junit:4.13>>> which is
+  an automatic module. It activates the internal provider <<<surefire-junit4>>> or <<<surefire-junit47>>> in the plugin.
+
++---+
+<properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.release>${java.specification.version}</maven.compiler.release>
+</properties>
+
+<dependencies>
+    <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>4.13</version>
+        <scope>test</scope>
+        <exclusions>
+            <exclusion>
+                <groupId>org.hamcrest</groupId>
+                <artifactId>hamcrest-core</artifactId>
+            </exclusion>
+        </exclusions>
+    </dependency>
+    <dependency>
+        <groupId>org.hamcrest</groupId>
+        <artifactId>hamcrest</artifactId>
+        <version>2.2</version>
+        <scope>test</scope>
+    </dependency>
+</dependencies>
++---+
+
+  The most important parts are the module descriptors. This is the module descriptor located in <<<src/main/java>>>:
+
++---+
+module main
+{
+    exports main;
+}
++---+
+
+  This is the module descriptor in <<<src/test/java>>>:
+
++---+
+module test
+{
+    requires main;
+    requires junit;
+    requires org.hamcrest;
+    exports test to junit;
+}
++---+
+
+* Examples using JUnit5
+
+  The Surefire project provides the integration tests with
+  {{{https://github.com/apache/maven-surefire/tree/master/surefire-its/src/test/resources/maven-multimodule-project-with-jpms}JUnit5}}
+  demonstrating the Java Modularity (JPMS) in Maven multi-module project.
+
+  The JDK version must be 9 or higher. The POM contains the dependency
+  <<<org.junit.jupiter:junit-jupiter-engine:5.6.2>>> which is named module. It activates the internal provider
+  <<<surefire-junit-platform>>> in the plugin.
+
++---+
+<artifactId>com.foo.impl</artifactId>
+
+<dependencies>
+    <dependency>
+        <groupId>com.foo</groupId>
+        <artifactId>com.foo.api</artifactId>
+        <version>${project.version}</version>
+    </dependency>
+    <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-simple</artifactId>
+    </dependency>
+    <dependency>
+        <groupId>org.junit.jupiter</groupId>
+        <artifactId>junit-jupiter-engine</artifactId>
+        <scope>test</scope>
+    </dependency>
+</dependencies>
++---+
+
+  The most important parts are the module descriptors. This is the module descriptor located in <<<src/main/java>>>:
+
++---+
+module com.foo.impl
+{
+    exports com.foo.impl;
+    requires com.foo.api;
+    requires org.slf4j;
+    requires org.slf4j.simple;
+}
++---+
+
+  This is the module descriptor in <<<src/test/java>>>:
+
++---+
+open module com.foo.test
+{
+    exports com.foo.implt;
+    requires com.foo.impl;
+    requires org.slf4j;
+    requires org.slf4j.simple;
+    requires transitive org.junit.jupiter.engine;
+    requires transitive org.junit.jupiter.api;
+}
++---+
diff --git a/maven-surefire-plugin/src/site/site.xml b/maven-surefire-plugin/src/site/site.xml
index b1f722c..0768638 100644
--- a/maven-surefire-plugin/src/site/site.xml
+++ b/maven-surefire-plugin/src/site/site.xml
@@ -38,6 +38,7 @@
       <item name="Download" href="../download.html"/>
     </menu>
     <menu name="Examples">
+      <item name="Java Modularity (JPMS) in Tests" href="examples/jpms.html"/>
       <item name="TCP/IP Communication between Forks" href="examples/process-communication.html"/>
       <item name="Using TestNG" href="examples/testng.html"/>
       <item name="Using JUnit" href="examples/junit.html"/>
diff --git a/surefire-its/src/test/resources/maven-multimodule-project-with-jpms/com.foo.impl/src/test/java/module-info.java b/surefire-its/src/test/resources/maven-multimodule-project-with-jpms/com.foo.impl/src/test/java/module-info.java
index 06000d0..1906b6a 100644
--- a/surefire-its/src/test/resources/maven-multimodule-project-with-jpms/com.foo.impl/src/test/java/module-info.java
+++ b/surefire-its/src/test/resources/maven-multimodule-project-with-jpms/com.foo.impl/src/test/java/module-info.java
@@ -19,6 +19,7 @@
 
 open module com.foo.test
 {
+    exports com.foo.implt;
     requires com.foo.impl;
     requires org.slf4j;
     requires org.slf4j.simple;