You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2022/11/15 12:46:04 UTC

[maven-site] branch master updated: Update guide-attached-tests.apt (#311)

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

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-site.git


The following commit(s) were added to refs/heads/master by this push:
     new ac0b82c3 Update guide-attached-tests.apt (#311)
ac0b82c3 is described below

commit ac0b82c3a4e33be11167604f4f679e9a988fd46c
Author: Florian Kleedorfer <fl...@austria.fm>
AuthorDate: Tue Nov 15 13:45:59 2022 +0100

    Update guide-attached-tests.apt (#311)
    
    The guide is incomplete.  Surefire does not pick up the tess in the attached jar on its own, it has to be configured to to so, and its provider autodetection does not work with attached jars, so it has to be nudged.
    
    With this change, the guide would have saved me an hour.
---
 content/apt/guides/mini/guide-attached-tests.apt | 32 ++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/content/apt/guides/mini/guide-attached-tests.apt b/content/apt/guides/mini/guide-attached-tests.apt
index 8b4b720f..a394ba89 100644
--- a/content/apt/guides/mini/guide-attached-tests.apt
+++ b/content/apt/guides/mini/guide-attached-tests.apt
@@ -54,7 +54,7 @@ Guide to using attached tests
   </build>
 </project>
 
-The attached test JAR can be installed and deployed like any other Maven artifact with 
+The attached test JAR can be installed and deployed like any other Maven artifact with
 
 To use the attached test JAR, specify a dependency on the main
 artifact with a specified type of <<<test-jar>>> and the <<<classifier>>>.
@@ -66,14 +66,42 @@ artifact with a specified type of <<<test-jar>>> and the <<<classifier>>>.
   <dependencies>
     <dependency>
       <groupId>com.myco.app</groupId>
-      <artifactId>foo</artifactId>
+      <artifactId>foo-core</artifactId>
       <version>1.0-SNAPSHOT</version>
       <classifier>tests</classifier>
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <!--
+        only needed if the test provider is not correctly autodetected by surefire
+        ... and you are using junit-jupiter (othewise, replace with your test framework)
+      -->
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <version>${junit.jupiter.version}</version> <!-- remember to set version as needed -->
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   ...
+  <build>
+    <plugins>
+      ...
+      <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>${surefire.version}</version> <!-- remember to set version as needed ->
+          <configuration>
+              <dependenciesToScan>
+                  <dependency>com.myco.app:foo-core:test-jar:tests</dependency>
+              </dependenciesToScan>
+          </configuration>
+      </plugin>
+      ...
+    </plugins>
+   </build>
+   ...
 </project>
 
 +----+