Skip to content

Respect composed JUnit test templates - #1093

Merged
timtebeek merged 1 commit into
openrewrite:mainfrom
martinfrancois:agent/repro-add-parameterized-meta-test-template
Oct 26, 2026
Merged

timtebeek merged 1 commit into
openrewrite:mainfrom
martinfrancois:agent/repro-add-parameterized-meta-test-template

Conversation

@martinfrancois

@martinfrancois martinfrancois commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Suggested review order: 15 of 52 (Score: 7)
Review first: openrewrite/rewrite-static-analysis#978

What's changed?

Leaves a method unchanged when an existing annotation is directly or transitively meta-annotated with JUnit's @TestTemplate. Methods without an existing test-template annotation still receive @ParameterizedTest when they use a supported parameter source.

What's your motivation?

Recipe: org.openrewrite.java.testing.junit5.AddParameterizedTestAnnotation.

I found this by running org.openrewrite.java.testing.junit5.AddParameterizedTestAnnotation from org.openrewrite.recipe:rewrite-testing-frameworks:3.42.0 on RepositorySourceResolverFuzzTest.java in Symphony-Trello at a8013f27. I reproduced the same result with the latest released recipe artifact, org.openrewrite.recipe:rewrite-testing-frameworks:3.44.0. The selected target tests still pass, but the recipe adds a redundant JUnit test-template annotation beside Jazzer's existing @FuzzTest.

Before

@MethodSource("labelledRepositorySourceValues")
@FuzzTest(maxDuration = "10s", maxExecutions = 20_000)
void labelledRepositorySourceValueCannotBreakSelectionInvariants(String rawValue) {

Actual after the recipe

@ParameterizedTest
@MethodSource("labelledRepositorySourceValues")
@FuzzTest(maxDuration = "10s", maxExecutions = 20_000)
void labelledRepositorySourceValueCannotBreakSelectionInvariants(String rawValue) {

Expected after the recipe

(unchanged)

@FuzzTest already participates in JUnit through @TestTemplate. Adding another test-template annotation does not improve the method and gives two extensions ownership of the same test declaration.

Confirmed real-world execution

Anything in particular you'd like reviewers to focus on?

Please review the use of AnnotationMatcher meta-annotation traversal for Jazzer and repository-defined composed annotations.

Have you considered any alternatives or workarounds?

Special-casing Jazzer would miss other composed JUnit test templates. Replacing @FuzzTest would disable the fuzzing engine, so recognizing the JUnit composition contract is the narrow behavior-preserving rule.

Any additional context

Pre-existing tests changed: None.

  • Target commit: martinfrancois/symphony-trello@a8013f27
  • Discovery release: org.openrewrite.recipe:rewrite-testing-frameworks:3.42.0
  • Latest verification release: org.openrewrite.recipe:rewrite-testing-frameworks:3.44.0
  • Second affected file: src/test/java/ch/fmartin/symphony/trello/tracker/TrelloCardReferenceParserFuzzTest.java
  • Target verification: the selected transformed tests execute 38 tests successfully; this PR prevents the redundant annotation change
  • Focused tests: AddParameterizedTestAnnotationTest

This change was prepared with AI assistance. I reviewed the target execution evidence, implementation, tests, and contribution text.

Checklist

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Aug 15, 2026
@martinfrancois martinfrancois changed the title Respect meta-annotated JUnit test templates Respect composed JUnit test templates Aug 15, 2026
@martinfrancois
martinfrancois force-pushed the agent/repro-add-parameterized-meta-test-template branch 2 times, most recently from 39e1fee to b677586 Compare August 16, 2026 02:53
@martinfrancois
martinfrancois force-pushed the agent/repro-add-parameterized-meta-test-template branch from b677586 to 763f40e Compare August 16, 2026 12:23
@martinfrancois
martinfrancois marked this pull request as ready for review August 17, 2026 08:05
@timtebeek
timtebeek merged commit 4816fc1 into openrewrite:main Oct 26, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants