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
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Compiles src/broken/MethodOrdererDefaultDemo.java against both JUnit versions and captures the
# REAL compiler output. MethodOrderer.Default was added in JUnit 6.0; this file is excluded from the
# normal build (it lives under src/broken, not src/test) precisely because it will not compile on 5.x.
set -uo pipefail
cd "$(dirname "$0")/.."
mvn -q -B dependency:build-classpath -Dmdep.outputFile=/tmp/cp-6.1.3.txt
mvn -q -B dependency:build-classpath -Dmdep.outputFile=/tmp/cp-5.14.4.txt -Djunit.version=5.14.4
mkdir -p /tmp/broken-compile-out/6 /tmp/broken-compile-out/5
{
echo '$ javac -cp <junit-jupiter-6.1.3 and its dependencies> src/broken/MethodOrdererDefaultDemo.java'
javac -cp "$(cat /tmp/cp-6.1.3.txt)" -d /tmp/broken-compile-out/6 src/broken/MethodOrdererDefaultDemo.java
echo "(compiled cleanly)"
} > output/15-broken-compile-junit6.1.3.txt 2>&1
{
echo '$ javac -cp <junit-jupiter-5.14.4 and its dependencies> src/broken/MethodOrdererDefaultDemo.java'
javac -cp "$(cat /tmp/cp-5.14.4.txt)" -d /tmp/broken-compile-out/5 src/broken/MethodOrdererDefaultDemo.java
} > output/16-broken-compile-junit5.14.4.txt 2>&1
cat output/15-broken-compile-junit6.1.3.txt
echo
cat output/16-broken-compile-junit5.14.4.txt
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Captures the real Surefire console output of LoanDeskTest run with no filter, -Dgroups=fast, and
# -Dgroups=slow - this is what a reader actually sees typing these commands, not a paraphrase.
set -uo pipefail
cd "$(dirname "$0")/.."
{
echo '$ mvn test -Dtest=LoanDeskTest (no tag filter - everything runs)'
mvn -B test -Dtest=LoanDeskTest 2>&1 | sed -n '/T E S T S/,/^\[INFO\] Results/p'
echo
echo '$ mvn test -Dgroups=fast -Dtest=LoanDeskTest'
mvn -B test -Dgroups=fast -Dtest=LoanDeskTest 2>&1 | sed -n '/T E S T S/,/^\[INFO\] Results/p'
echo
echo '$ mvn test -Dgroups=slow -Dtest=LoanDeskTest'
mvn -B test -Dgroups=slow -Dtest=LoanDeskTest 2>&1 | sed -n '/T E S T S/,/^\[INFO\] Results/p'
} > output/17-mvn-cli-tag-filter.txt
cat output/17-mvn-cli-tag-filter.txt
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Regenerates every file in output/ from scratch. Requires JDK 17+ and Maven on PATH.
set -euo pipefail
cd "$(dirname "$0")/.."
rm -rf output
mkdir -p output
echo "== 1/4: full suite on the default version (JUnit 6.1.3) =="
mvn -q -B test
echo "== 2/4: same suite on JUnit 5.14.4, keep only the two version-sensitive transcripts =="
mvn -q -B test -Djunit.version=5.14.4
cp output/12-nested-sibling-order-run1.txt output/12-nested-sibling-order-junit5.14.4.txt
cp output/14-method-order-inheritance.txt output/14-method-order-inheritance-junit5.14.4.txt
echo "== 3/4: back to the default version so output/ reflects JUnit 6.1.3 everywhere else =="
mvn -q -B test
echo "== 4/4: compiler-message transcripts for the broken/ demo, and a real mvn CLI tag-filter run =="
./scripts/broken-compile.sh
./scripts/mvn-cli-tag-filter.sh
echo "Done. See output/ for every transcript the article links to."