Skip to content

Comments

Add JDK cross-version compatibility tests#162

Closed
pshevche wants to merge 1 commit intomainfrom
161-jdk-cross-version-tests
Closed

Add JDK cross-version compatibility tests#162
pshevche wants to merge 1 commit intomainfrom
161-jdk-cross-version-tests

Conversation

@pshevche
Copy link
Owner

Summary

Extends the Kotlin compatibility test suite to verify that the Spockk compiler plugin works correctly across different JDK versions.

Changes

  • Extended Workspace fixture to support JDK version configuration via Gradle toolchain
  • Updated SpockkKotlinCompatibilityTest to test combinations of:
    • 5 Kotlin versions: 1.8.22, 1.9.25, 2.0.21, 2.1.21, 2.2.21
    • 2 JDK versions: 21, 25
    • Total: 10 test combinations
  • Configured CI to provision JDK 21 and 25 in the setup-gradle action
  • Added JDK environment variable exports for test execution (JDK21, JDK25)

Test Coverage

The test suite verifies that the Spockk compiler plugin successfully transforms and executes specifications when compiling with different Kotlin compiler versions on different JDK runtimes.

Why JDK 21 and 25?

  • JDK 21: Current LTS version, widely adopted
  • JDK 25: Latest LTS version, ensures forward compatibility

Implementation Details

Workspace Fixture

Added optional jdkVersion parameter to setup() method that injects Gradle toolchain configuration:

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(jdkVersion)
    }
}

Test Structure

Used a data class to encapsulate version combinations:

data class KotlinAndJdkVersions(
    val kotlinVersion: String,
    val jdkVersion: Int
)

The test uses Spock's where block with a pre-computed list of all combinations for clean, maintainable test data.

CI Configuration

Moved JDK setup to the reusable setup-gradle action for consistency across workflows:

  • Sets up JDK 21 (for Gradle daemon)
  • Sets up JDK 25 (for cross-version testing)
  • Exports environment variables for both JDKs

Test Plan

  • Tests compile successfully
  • Test structure verified (10 combinations generated)
  • CI workflow provisions JDKs correctly
  • Tests pass in CI with proper JDK environment variables

🤖 Generated with Claude Code

Extends the Kotlin compatibility test suite to verify that the Spockk
compiler plugin works correctly across different JDK versions.

Changes:
- Extended Workspace fixture to support JDK version configuration via
  Gradle toolchain
- Updated SpockkKotlinCompatibilityTest to test combinations of Kotlin
  versions (1.8.22, 1.9.25, 2.0.21, 2.1.21, 2.2.21) with JDK versions
  (21, 25)
- Configured CI to provision JDK 21 and 25 in setup-gradle action
- Added JDK environment variable exports for test execution

The test suite now verifies 10 (Kotlin, JDK) combinations to ensure
the compiler plugin is compatible with different JDK environments.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-project-automation github-project-automation bot moved this to Todo in spockk Feb 10, 2026
@pshevche pshevche added this to the v0.3.0 milestone Feb 10, 2026
@pshevche pshevche moved this from Todo to In progress in spockk Feb 10, 2026
@pshevche pshevche removed this from the v0.3.0 milestone Feb 10, 2026
@pshevche pshevche linked an issue Feb 10, 2026 that may be closed by this pull request
@pshevche
Copy link
Owner Author

Kotlin does not yet support the JDK25 target. So, this change will have to wait.

@pshevche pshevche closed this Feb 10, 2026
@github-project-automation github-project-automation bot moved this from In progress to Done in spockk Feb 10, 2026
@pshevche pshevche deleted the 161-jdk-cross-version-tests branch February 10, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add cross-version tests for different JDK versions

1 participant