Skip to content

add @WithGradleVersionsLessThan, @WithGradleVersionsGreaterThan, @WithGradleVersionsLessThanOrEqualTo and @WithGradleVersionsGreaterThanOrEqualTo#338

Open
FinlayRJW wants to merge 1 commit intofinlayw/with-onlyfrom
finlayw/with-other
Open

add @WithGradleVersionsLessThan, @WithGradleVersionsGreaterThan, @WithGradleVersionsLessThanOrEqualTo and @WithGradleVersionsGreaterThanOrEqualTo#338
FinlayRJW wants to merge 1 commit intofinlayw/with-onlyfrom
finlayw/with-other

Conversation

@FinlayRJW
Copy link
Copy Markdown
Contributor

Before this PR

When writing tests that need to run on specific Gradle version ranges (e.g., only pre-8.0 versions, or 8.5+), users had to either:

  1. Use @WithOnlyGradleVersions and manually list every version in the range
  2. Add conditional logic inside the test itself

This is tedious and error-prone, especially as new Gradle versions are added to the test matrix.

After this PR

Adds four new annotations for filtering tests by Gradle version comparisons:

  • @WithGradleVersionsLessThan("8.0") - run only on versions < 8.0
  • @WithGradleVersionsGreaterThan("7.6") - run only on versions > 7.6
  • @WithGradleVersionsLessThanOrEqualTo("8.5") - run only on versions <= 8.5
  • @WithGradleVersionsGreaterThanOrEqualTo("8.0") - run only on versions >= 8.0

These can be combined for version ranges:

@Test
@WithGradleVersionsGreaterThanOrEqualTo("8.0")
@WithGradleVersionsLessThan("9.0")
void test_gradle_8_only(GradleInvoker gradle, RootProject project) {
    // Runs on Gradle 8.x versions only
}

Version comparison uses Gradle's built-in GradleVersion class for proper semantic version ordering.

==COMMIT_MSG==
Add version comparison annotations for Gradle version filtering

Adds @WithGradleVersionsLessThan, @WithGradleVersionsGreaterThan,
@WithGradleVersionsLessThanOrEqualTo, and @WithGradleVersionsGreaterThanOrEqualTo
annotations that filter tests to run only on Gradle versions matching the comparison.

Annotations can be combined for version ranges (e.g., >= 8.0 AND < 9.0).
==COMMIT_MSG==

Possible downsides?

None - this is purely additive functionality.

@FinlayRJW FinlayRJW changed the title add other annotations add @WithGradleVersionsLessThan, @WithGradleVersionsGreaterThan, @WithGradleVersionsLessThanOrEqualTo and @WithGradleVersionsGreaterThanOrEqualTo Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant