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

pjfanning pushed a commit to branch junit-jupiter
in repository https://gitbox.apache.org/repos/asf/pekko-quickstart-java.g8.git

commit ed8024bd36f91ac496abaef2bb9e37187f5ddb48
Author: PJ Fanning <[email protected]>
AuthorDate: Wed Sep 30 17:11:09 2026 +0100

    Switch template tests from JUnit 4 to JUnit Jupiter
    
    Use JUnit 6 (Jupiter) with Pekko's TestKitJUnit5Extension in the sbt,
    Maven and Gradle builds. sbt needs the sbt-jupiter-interface plugin for
    test discovery; its sbt 2 builds require JUnit 6, so generated projects
    now need Java 17 (Maven compiles with release 17, README updated).
    
    Fix CI so it actually tests the templated app: g8Test/scripted skipped
    it because the template uses sbt 2 while this build is on sbt 1. CI now
    renders the template and runs `sbt testFull` and `mvn test` in target/g8.
    
    Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
---
 .github/workflows/build-test.yml                        | 17 ++++++++++++++---
 README.md                                               |  2 +-
 docs/src/main/paradox/testing-actors.md                 |  7 ++++---
 src/main/g8/build.gradle                                |  8 +++++++-
 src/main/g8/build.sbt                                   |  4 ++--
 src/main/g8/pom.xml                                     | 14 +++++++++-----
 src/main/g8/project/plugins.sbt                         |  1 +
 .../g8/src/test/java/$package$/PekkoQuickstartTest.java | 15 ++++++++++-----
 8 files changed, 48 insertions(+), 20 deletions(-)

diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index 4e9e2b8..2b52c5a 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -25,6 +25,17 @@ jobs:
       - name: Cache Coursier cache
         uses: coursier/cache-action@95e5b1029b6b86e7bac033ee44a0697d8a527d2d # 
v8.1.1
 
-      - name: sbt test
-        # This runs the template with the default parameters, and runs test 
within the templated app.
-        run: sbt -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M test 
docs/paradox
+      - name: Render template and build docs
+        # This renders the template with the default parameters into target/g8.
+        run: sbt -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M g8 
docs/paradox
+
+      - name: sbt test in templated app
+        # Run directly rather than via g8Test: scripted skips the test because 
the
+        # templated app uses sbt 2 while this build (paradox) is still on sbt 
1.
+        # testFull, because sbt 2's `test` is testQuick and may skip cached 
passes.
+        working-directory: target/g8
+        run: sbt -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M testFull
+
+      - name: mvn test in templated app
+        working-directory: target/g8
+        run: mvn -B test
diff --git a/README.md b/README.md
index 8d099a4..1c86ca1 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ The Hello World example illustrates Pekko basics. Within 30 
minutes, you should
 It can also be used as a [Giter8][g8] template for Pekko with Java.
 
 Prerequisites:
-- JDK 8
+- JDK 17
 - [sbt][sbt] 1.2.8 or higher ([download here][sbt_download])
 
 Open a console and run the following command to apply this template:
diff --git a/docs/src/main/paradox/testing-actors.md 
b/docs/src/main/paradox/testing-actors.md
index dd63874..fcc90e4 100644
--- a/docs/src/main/paradox/testing-actors.md
+++ b/docs/src/main/paradox/testing-actors.md
@@ -1,6 +1,6 @@
 ## Testing Actors
  
-The tests in the Hello World example illustrates use of the 
[JUnit](https://www.junit.org/) framework. The test coverage is not complete. 
+The tests in the Hello World example illustrates use of the [JUnit 
Jupiter](https://junit.org/) framework. The test coverage is not complete. 
 It shows how to test actor code and provides some basic concepts. 
 
 @@snip 
[PekkoQuickstartTest.java]($g8srctest$/java/$package$/PekkoQuickstartTest.java)
@@ -9,8 +9,9 @@ It shows how to test actor code and provides some basic 
concepts.
 
 @@snip 
[PekkoQuickstartTest.java]($g8srctest$/java/$package$/PekkoQuickstartTest.java) 
{ #definition }
 
-Support for JUnit is included by using the `TestKitJunitResource` JUnit rule. 
This automatically creates and cleans
-up an `ActorTestKit`. To see how to use the testkit directly see the [full 
documentation](https://pekko.apache.org/docs/pekko/current/typed/testing-async.html).
+Support for JUnit Jupiter is included by using the `TestKitJUnit5Extension` 
extension. The `ActorTestKit` field annotated
+with `@JUnit5TestKit` is shut down by the extension after all the tests in the 
class have run. `@TestInstance(PER_CLASS)`
+ensures that a single `ActorTestKit` is shared by all the tests in the class. 
To see how to use the testkit directly see the [full 
documentation](https://pekko.apache.org/docs/pekko/current/typed/testing-async.html).
 
 ### Test methods
 
diff --git a/src/main/g8/build.gradle b/src/main/g8/build.gradle
index 1f7bec6..a0fe657 100644
--- a/src/main/g8/build.gradle
+++ b/src/main/g8/build.gradle
@@ -12,11 +12,17 @@ dependencies {
   implementation 'org.apache.pekko:pekko-actor-typed_2.13:$pekko_version$'
   implementation 'ch.qos.logback:logback-classic:1.3.14'
   testImplementation 
'org.apache.pekko:pekko-actor-testkit-typed_2.13:$pekko_version$'
-  testImplementation 'junit:junit:4.13.2'
+  testImplementation platform('org.junit:junit-bom:6.0.3')
+  testImplementation 'org.junit.jupiter:junit-jupiter'
+  testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
 }
 
 mainClassName = "$package$.PekkoQuickstart"
 
+test {
+  useJUnitPlatform()
+}
+
 run {
   standardInput = System.in
 }
diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt
index bc10a95..b335e64 100644
--- a/src/main/g8/build.sbt
+++ b/src/main/g8/build.sbt
@@ -16,5 +16,5 @@ libraryDependencies ++= Seq(
   "org.apache.pekko" %% "pekko-actor-typed" % pekkoVersion,
   "org.apache.pekko" %% "pekko-actor-testkit-typed" % pekkoVersion,
   "ch.qos.logback" % "logback-classic" % "1.3.15",
-  "junit" % "junit" % "4.13.2" % Test,
-  "com.github.sbt" % "junit-interface" % "0.13.3" % Test)
+  "org.junit.jupiter" % "junit-jupiter" % "6.0.3" % Test,
+  "com.github.sbt.junit" % "jupiter-interface" % 
JupiterKeys.jupiterVersion.value % Test)
diff --git a/src/main/g8/pom.xml b/src/main/g8/pom.xml
index cecfb49..4e72662 100644
--- a/src/main/g8/pom.xml
+++ b/src/main/g8/pom.xml
@@ -28,9 +28,9 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.13.2</version>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter</artifactId>
+            <version>6.0.3</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
@@ -41,10 +41,14 @@
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>3.13.0</version>
                 <configuration>
-                    <source>1.8</source>
-                    <target>1.8</target>
+                    <release>17</release>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>3.5.5</version>
+            </plugin>
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>exec-maven-plugin</artifactId>
diff --git a/src/main/g8/project/plugins.sbt b/src/main/g8/project/plugins.sbt
new file mode 100644
index 0000000..1865083
--- /dev/null
+++ b/src/main/g8/project/plugins.sbt
@@ -0,0 +1 @@
+addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.19.0")
diff --git a/src/main/g8/src/test/java/$package$/PekkoQuickstartTest.java 
b/src/main/g8/src/test/java/$package$/PekkoQuickstartTest.java
index 2802e1d..11cbb55 100644
--- a/src/main/g8/src/test/java/$package$/PekkoQuickstartTest.java
+++ b/src/main/g8/src/test/java/$package$/PekkoQuickstartTest.java
@@ -1,16 +1,21 @@
 package $package$;
 
-import org.apache.pekko.actor.testkit.typed.javadsl.TestKitJunitResource;
+import org.apache.pekko.actor.testkit.typed.annotations.JUnit5TestKit;
+import org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit;
+import org.apache.pekko.actor.testkit.typed.javadsl.TestKitJUnit5Extension;
 import org.apache.pekko.actor.testkit.typed.javadsl.TestProbe;
 import org.apache.pekko.actor.typed.ActorRef;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.extension.ExtendWith;
 
 //#definition
+@ExtendWith(TestKitJUnit5Extension.class)
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
 public class PekkoQuickstartTest {
 
-    @ClassRule
-    public static final TestKitJunitResource testKit = new 
TestKitJunitResource();
+    @JUnit5TestKit
+    public final ActorTestKit testKit = ActorTestKit.create();
 //#definition
 
     //#test


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to