Add conditional module: JUnit conditional test execution on 6.1.3 (JDK 25)
Fixtures for the OS, JRE, system property, environment variable and EnabledIf conditions plus a custom ExecutionCondition, run through the JUnit Platform launcher (in-process and in child JVMs) to capture real skip reasons; skipped versus aborted lifecycle; stacking, class-level skips and the deactivate switch; the 2025 article's code compiled as published; and a javap comparison of the condition package in 5.14.4 and 6.1.3. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01G8ikz8xdWuTP5yun8DZ1hk
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
This machine: os.name=Linux, os.arch=amd64, java.version=25.0.4.1
|
||||
OS.current()=LINUX, JRE.currentVersion()=JAVA_25
|
||||
|
||||
OsConditionalTest
|
||||
runEverywhereButSolaris() : PASSED
|
||||
testUnixSocketBehavior() : PASSED
|
||||
testWindowsRegistryAccess() : SKIPPED (Disabled on operating system: Linux)
|
||||
|
||||
JreConditionalTest
|
||||
hideFromExperimentalVersions() : PASSED
|
||||
testLegacyCompatibility() : SKIPPED (Disabled on JRE version: 25.0.4.1)
|
||||
testLtsFeatureSet() : SKIPPED (Disabled on JRE version: 25.0.4.1)
|
||||
@@ -0,0 +1,7 @@
|
||||
This machine: os.name=Linux, os.arch=amd64, java.version=25.0.4.1
|
||||
OS.current()=LINUX, JRE.currentVersion()=JAVA_25
|
||||
|
||||
ArchitectureConditionalTest
|
||||
anythingButArm() : PASSED
|
||||
onlyArmLinux() : SKIPPED (Disabled on operating system: Linux (amd64))
|
||||
onlyIntelLinux() : PASSED
|
||||
@@ -0,0 +1,13 @@
|
||||
SystemPropertyTest in a fresh JVM, three times.
|
||||
|
||||
No -D flags:
|
||||
runOnlyHighSeverityTests() : SKIPPED (System property [test.severity] does not exist)
|
||||
testEnglishLocalization() : PASSED
|
||||
|
||||
-Dtest.severity=high -Duser.language=fr (the command line from the 2025 article):
|
||||
runOnlyHighSeverityTests() : PASSED
|
||||
testEnglishLocalization() : SKIPPED (System property [user.language] with value [fr] does not match regular expression [en])
|
||||
|
||||
-Dtest.severity=low -Duser.language=en:
|
||||
runOnlyHighSeverityTests() : SKIPPED (System property [test.severity] with value [low] does not match regular expression [critical|high])
|
||||
testEnglishLocalization() : PASSED
|
||||
@@ -0,0 +1,13 @@
|
||||
PipelineTest in a fresh JVM, three times, with the environment set by the test.
|
||||
|
||||
CI unset, ENV=DEV (a developer laptop):
|
||||
integrationWithExternalAPI() : SKIPPED (Environment variable [ENV] with value [DEV] does not match regular expression [STAGING])
|
||||
performanceBenchmark() : SKIPPED (Environment variable [CI] does not exist)
|
||||
|
||||
CI=true, ENV=STAGING (a pipeline):
|
||||
integrationWithExternalAPI() : PASSED
|
||||
performanceBenchmark() : PASSED
|
||||
|
||||
CI=false, ENV unset:
|
||||
integrationWithExternalAPI() : SKIPPED (Environment variable [ENV] does not exist)
|
||||
performanceBenchmark() : SKIPPED (Environment variable [CI] with value [false] does not match regular expression [true])
|
||||
@@ -0,0 +1,19 @@
|
||||
The WeekendCondition from the 2025 article, run today (2026-10-11, a SUNDAY):
|
||||
weeklyBackupStabilityTest() : PASSED
|
||||
|
||||
The reusable version, @EnabledOnDays + DayOfWeekCondition, with the day pinned by the configuration parameter demo.today.
|
||||
|
||||
demo.today=SATURDAY
|
||||
noAnnotationRunsAlways() : PASSED
|
||||
wednesdayOnly() : SKIPPED (Today is SATURDAY, test runs on [WEDNESDAY])
|
||||
weekendOnly() : PASSED
|
||||
|
||||
demo.today=WEDNESDAY
|
||||
noAnnotationRunsAlways() : PASSED
|
||||
wednesdayOnly() : PASSED
|
||||
weekendOnly() : SKIPPED (Today is WEDNESDAY, test runs on [SATURDAY, SUNDAY])
|
||||
|
||||
demo.today=FRIDAY
|
||||
noAnnotationRunsAlways() : PASSED
|
||||
wednesdayOnly() : SKIPPED (Today is FRIDAY, test runs on [WEDNESDAY])
|
||||
weekendOnly() : SKIPPED (Today is FRIDAY, test runs on [SATURDAY, SUNDAY])
|
||||
@@ -0,0 +1,14 @@
|
||||
Results
|
||||
a_runs() : PASSED
|
||||
b_skippedByAnnotation() : SKIPPED (Disabled on operating system: Linux)
|
||||
c_abortedByAssumption() : ABORTED (Assumption failed: database is down)
|
||||
|
||||
Every callback and test body that ran, in order
|
||||
@BeforeEach a_runs
|
||||
body a_runs
|
||||
@AfterEach a_runs
|
||||
@BeforeEach c_abortedByAssumption
|
||||
@AfterEach c_abortedByAssumption
|
||||
|
||||
The AssumptionTest from the 2025 article, unchanged
|
||||
testDatabaseConnection() : ABORTED (Assumption failed: Aborting: Database is not reachable.)
|
||||
@@ -0,0 +1,18 @@
|
||||
This machine: os.name=Linux, os.arch=amd64, java.version=25.0.4.1
|
||||
OS.current()=LINUX, JRE.currentVersion()=JAVA_25
|
||||
|
||||
StackingConditionalTest
|
||||
bothConditionsFalse() : SKIPPED (Disabled on operating system: Linux)
|
||||
methodConditionDefaultReason() : SKIPPED (@EnabledIf("alwaysFalse") evaluated to false)
|
||||
methodConditionOwnReason() : SKIPPED (feature flag is off)
|
||||
onlySecondConditionFalse() : SKIPPED (System property [never.set] does not exist)
|
||||
withOwnReason() : SKIPPED (Disabled on operating system: Linux ==> Needs the Windows registry)
|
||||
|
||||
ClassLevelConditionalTest (@EnabledOnOs(WINDOWS) on the class, two test methods)
|
||||
ClassLevelConditionalTest : CONTAINER SKIPPED (Disabled on operating system: Linux)
|
||||
|
||||
OsConditionalTest again, with the configuration parameter
|
||||
junit.jupiter.conditions.deactivate=org.junit.jupiter.api.condition.*
|
||||
runEverywhereButSolaris() : PASSED
|
||||
testUnixSocketBehavior() : PASSED
|
||||
testWindowsRegistryAccess() : PASSED
|
||||
@@ -0,0 +1,12 @@
|
||||
# The 2025 article's code blocks, compiled exactly as published, against JUnit Jupiter 6.1.3 on JDK 25.0.4.1
|
||||
|
||||
AssumptionTest: compiles
|
||||
JreConditionalTest: compiles
|
||||
OsConditionalTest: compiles
|
||||
PipelineTest: compiles
|
||||
SystemPropertyTest: compiles
|
||||
WeekendCondition: DOES NOT COMPILE
|
||||
src/old/WeekendCondition.java:19: error: cannot find symbol
|
||||
symbol: class Test
|
||||
location: class CustomConditionTest
|
||||
1 error
|
||||
@@ -0,0 +1,20 @@
|
||||
# org/junit/jupiter/api/condition in junit-jupiter-api 5.14.4 (last JUnit 5 release on Maven Central) and 6.1.3
|
||||
|
||||
class file major version of EnabledOnOs in 5.14.4: 52 (52 = Java 8, 61 = Java 17)
|
||||
class file major version of EnabledOnOs in 6.1.3: 61 (52 = Java 8, 61 = Java 17)
|
||||
|
||||
classes in the package: 39 in 5.14.4, 40 in 6.1.3
|
||||
classes only in 6.1.3: org/junit/jupiter/api/condition/package-info.class
|
||||
classes only in 5.14.4:
|
||||
|
||||
classes with an identical public and protected signature (javap): 37
|
||||
classes whose signature differs: org.junit.jupiter.api.condition.AbstractJreRangeCondition org.junit.jupiter.api.condition.JRE
|
||||
|
||||
diff of javap org.junit.jupiter.api.condition.AbstractJreRangeCondition (5.14.4 -> 6.1.3):
|
||||
4a5
|
||||
> static {};
|
||||
|
||||
diff of javap org.junit.jupiter.api.condition.JRE (5.14.4 -> 6.1.3):
|
||||
22a23,24
|
||||
> public static final org.junit.jupiter.api.condition.JRE JAVA_27;
|
||||
> public static final org.junit.jupiter.api.condition.JRE JAVA_28;
|
||||
Reference in New Issue
Block a user