Add organising module: DisplayNameGenerator/@Nested/@Tag demos on JUnit 6.1.3

Companion code for the rewritten post "Organising and Displaying JUnit Tests:
@DisplayName, @Nested, @Tag (JUnit 5 -> JUnit 6)". Same suite also runs green
on JUnit 5.14.4 via -Djunit.version. Verified, not assumed: GA dates and
versions cross-checked against Maven Central metadata and docs.junit.org
release notes; the @TestMethodOrder-inheritance-into-@Nested-classes and
MethodOrderer.Default/ClassOrderer.Default behaviour differences between
5.14.4 and 6.1.3 are demonstrated by actually running the same source under
both engines (see organising/output/12-* and 14-*), not by reading about them.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YXCrLgRKFgCh9RHKW8xaqJ
This commit is contained in:
2026-10-01 04:38:28 +00:00
co-authored by Claude Sonnet 5
parent cfc6c79fc3
commit bfc67986bc
43 changed files with 1124 additions and 0 deletions
@@ -0,0 +1,3 @@
+ DisplayNameFixtures$PlainDefault
- total_price_is_zero_when_cart_is_empty()
- addingAnItemIncreasesTheCount()
@@ -0,0 +1,3 @@
+ DisplayNameFixtures$Underscored
- total price is zero when cart is empty
- adding an item increases the count
@@ -0,0 +1,4 @@
+ A shopping cart
- has a total of zero when it is empty
+ once an item has been added
- has a total equal to that item's price
@@ -0,0 +1,3 @@
+ Custom sentence case
- Should report zero for an empty cart()
- Should reject a negative quantity(TestInfo)
+2
View File
@@ -0,0 +1,2 @@
+ DisplayNameFixtures$ConfiguredByDefault
- total_price_is_zero_when_cart_is_empty()
@@ -0,0 +1,2 @@
+ DisplayNameFixtures$ConfiguredByDefault
- total price is zero when cart is empty
@@ -0,0 +1,6 @@
catalog.priceLookupIsCaseInsensitive ran
catalog.emptyQueryReturnsNoResults ran
-- results --
SUCCESSFUL priceLookupIsCaseInsensitive()
SUCCESSFUL emptyQueryReturnsNoResults()
SUCCESSFUL TagFixtures$CatalogServiceTest
@@ -0,0 +1,6 @@
catalog.priceLookupIsCaseInsensitive ran
catalog.emptyQueryReturnsNoResults ran
-- results --
SUCCESSFUL priceLookupIsCaseInsensitive()
SUCCESSFUL emptyQueryReturnsNoResults()
SUCCESSFUL TagFixtures$CatalogServiceTest
@@ -0,0 +1,6 @@
catalog.reindexingHitsTheRealSearchCluster ran
catalog.priceLookupIsCaseInsensitive ran
-- results --
SUCCESSFUL reindexingHitsTheRealSearchCluster()
SUCCESSFUL priceLookupIsCaseInsensitive()
SUCCESSFUL TagFixtures$CatalogServiceTest
@@ -0,0 +1,6 @@
catalog.priceLookupIsCaseInsensitive ran
catalog.emptyQueryReturnsNoResults ran
-- results --
SUCCESSFUL priceLookupIsCaseInsensitive()
SUCCESSFUL emptyQueryReturnsNoResults()
SUCCESSFUL TagFixtures$CatalogServiceTest
@@ -0,0 +1,4 @@
TrimmedTagClass.stillRuns ran
-- results --
SUCCESSFUL stillRuns()
SUCCESSFUL TagFixtures$TrimmedTagClass
@@ -0,0 +1,4 @@
TrimmedTagClass.stillRuns ran
-- results --
SUCCESSFUL stillRuns()
SUCCESSFUL TagFixtures$TrimmedTagClass
@@ -0,0 +1,4 @@
InternalWhitespaceTagClass.stillRunsButTagIsDropped ran
-- results --
SUCCESSFUL stillRunsButTagIsDropped()
SUCCESSFUL TagFixtures$InternalWhitespaceTagClass
@@ -0,0 +1 @@
-- results --
@@ -0,0 +1,4 @@
BlankTagClass.neverActuallyRuns ran
-- results --
SUCCESSFUL neverActuallyRuns()
SUCCESSFUL TagFixtures$BlankTagClass
@@ -0,0 +1,9 @@
+ OrderingFixtures$DefaultSiblingOrder
+ Delta
- t()
+ Alpha
- t()
+ Mike
- t()
+ Zebra
- t()
@@ -0,0 +1,9 @@
+ OrderingFixtures$DefaultSiblingOrder
+ Alpha
- t()
+ Delta
- t()
+ Zebra
- t()
+ Mike
- t()
@@ -0,0 +1,9 @@
+ OrderingFixtures$DefaultSiblingOrder
+ Alpha
- t()
+ Delta
- t()
+ Zebra
- t()
+ Mike
- t()
@@ -0,0 +1,9 @@
+ OrderingFixtures$DefaultSiblingOrder
+ Alpha
- t()
+ Delta
- t()
+ Zebra
- t()
+ Mike
- t()
@@ -0,0 +1,10 @@
+ OrderingFixtures$ClassOrderOuter
+ Alpha
- t()
+ Mike
- t()
+ Zebra
+ Charlie
- t()
+ Delta
- t()
@@ -0,0 +1,8 @@
+ OrderingFixtures$MethodOrderInheritanceOuter
- alpha()
- bravo()
- charlie()
+ PlainNestedChild
- yankee()
- xray()
- zulu()
@@ -0,0 +1,8 @@
+ OrderingFixtures$MethodOrderInheritanceOuter
- alpha()
- bravo()
- charlie()
+ PlainNestedChild
- xray()
- yankee()
- zulu()
@@ -0,0 +1,3 @@
$ javac -cp <junit-jupiter-6.1.3 and its dependencies> src/broken/MethodOrdererDefaultDemo.java
Picked up JAVA_TOOL_OPTIONS: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36237 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
(compiled cleanly)
@@ -0,0 +1,8 @@
$ javac -cp <junit-jupiter-5.14.4 and its dependencies> src/broken/MethodOrdererDefaultDemo.java
Picked up JAVA_TOOL_OPTIONS: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36237 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
src/broken/MethodOrdererDefaultDemo.java:22: error: cannot find symbol
@TestMethodOrder(MethodOrderer.Default.class) // <-- does not exist before JUnit 6.0
^
symbol: class Default
location: interface MethodOrderer
1 error
@@ -0,0 +1,38 @@
$ mvn test -Dtest=LoanDeskTest (no tag filter - everything runs)
[INFO] T E S T S
[INFO] -------------------------------------------------------
Picked up JAVA_TOOL_OPTIONS: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36237 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
[INFO] Running com.ankurm.tutorials.junit.organising.LoanDeskTest
[INFO] Running When no books are on loan
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.162 s -- in When no books are on loan
[INFO] Running When a book is ten days overdue
[INFO] Running and the member disputes the fee
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 s -- in and the member disputes the fee
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.075 s -- in When a book is ten days overdue
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.289 s -- in com.ankurm.tutorials.junit.organising.LoanDeskTest
[INFO]
[INFO] Results:
$ mvn test -Dgroups=fast -Dtest=LoanDeskTest
[INFO] T E S T S
[INFO] -------------------------------------------------------
Picked up JAVA_TOOL_OPTIONS: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36237 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
[INFO] Running com.ankurm.tutorials.junit.organising.LoanDeskTest
[INFO] Running When no books are on loan
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.149 s -- in When no books are on loan
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.201 s -- in com.ankurm.tutorials.junit.organising.LoanDeskTest
[INFO]
[INFO] Results:
$ mvn test -Dgroups=slow -Dtest=LoanDeskTest
[INFO] T E S T S
[INFO] -------------------------------------------------------
Picked up JAVA_TOOL_OPTIONS: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36237 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
[INFO] Running com.ankurm.tutorials.junit.organising.LoanDeskTest
[INFO] Running When a book is ten days overdue
[INFO] Running and the member disputes the fee
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 s -- in and the member disputes the fee
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.170 s -- in When a book is ten days overdue
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.205 s -- in com.ankurm.tutorials.junit.organising.LoanDeskTest
[INFO]
[INFO] Results: