Skip to content

Add @RestrictToGradleVersionsEqualTo annotation for filtering test matrix#337

Open
FinlayRJW wants to merge 31 commits into
developfrom
finlayw/with-only
Open

Add @RestrictToGradleVersionsEqualTo annotation for filtering test matrix#337
FinlayRJW wants to merge 31 commits into
developfrom
finlayw/with-only

Conversation

@FinlayRJW
Copy link
Copy Markdown
Contributor

@FinlayRJW FinlayRJW commented Jan 6, 2026

Before this PR

When using @RestrictToGradleVersionsEqualTo, you can only add versions to the test matrix. There's no way to restrict a specific test to run against only certain versions from the matrix. If you need to run a test against just one Gradle version (e.g., for version-specific behavior testing), you had to run it against
all configured versions.

After this PR

Introduces @RestrictToGradleVersionsEqualTo annotation that filters the test matrix to only include specified versions:

  • Can be applied at class level (filters the entire test class matrix upfront) or method level (skips non-matching versions)
  • Versions not in the matrix are simply not run (no error)
  • Can be combined with @RestrictToGradleVersionsEqualTo to first add a version then filter to only that version: @WithSpecialCaseGradleVersionsCondition("8.5") @RestrictToGradleVersionsEqualTo("8.5")
  • Supports an optional reason parameter to document why specific versions are required

==COMMIT_MSG==
Add @RestrictToGradleVersionsEqualTo annotation
==COMMIT_MSG==

Possible downsides?

  • If a user specifies a version in @RestrictToGradleVersionsEqualTo that isn't in the matrix, the test silently doesn't run (by design, but could be surprising)

Comment thread docs/testing-guide.md Outdated

#### Filtering to Specific Versions

Use `@WithOnlyGradleVersions` to filter the test matrix to only run on specific Gradle versions. Unlike `@WithGradleVersions` which adds versions, this annotation restricts which versions from the matrix will actually run.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name @WithOnlyGradleVersions could imply an authoritative list of versions you run the test with. This can be confusing.

Copy link
Copy Markdown
Contributor Author

@FinlayRJW FinlayRJW Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about RestrictToGradleVersionsEqualTo I think that implies it only filters?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we can add RestrictToGradleVersionsGreaterThan etc later

@FinlayRJW FinlayRJW changed the title Add @WithOnlyGradleVersions annotation for filtering test matrix Add @RestrictToGradleVersions annotation for filtering test matrix Jan 9, 2026
@FinlayRJW FinlayRJW changed the title Add @RestrictToGradleVersions annotation for filtering test matrix Add @RestrictToGradleVersionsEqualTo annotation for filtering test matrix Jan 9, 2026
@FinlayRJW FinlayRJW changed the base branch from finlayw/additional-gradle-versions to develop January 12, 2026 15:22
@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented Jan 12, 2026

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Add @RestrictToGradleVersionsEqualTo annotation

Check the box to generate changelog(s)

  • Generate changelog entry

@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented Jan 26, 2026

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

💡 Improvements

  • Add @RestrictToGradleVersionsEqualTo annotation (#337)

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.

2 participants