Skip to content

test: add for final TestName Rule - #1109

Merged
timtebeek merged 2 commits into
openrewrite:mainfrom
cortlepp:fix/test-rule-final
Aug 26, 2026
Merged

test: add for final TestName Rule#1109
timtebeek merged 2 commits into
openrewrite:mainfrom
cortlepp:fix/test-rule-final

Conversation

@cortlepp

Copy link
Copy Markdown
Contributor

What's changed?

Fix a bug where if the TestName rule is final, after the rewrite the String is still final (which leads to a compilation error).

What's your motivation?

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

Anyone you would like to review specifically?

@timtebeek

Have you considered any alternatives or workarounds?

Any additional context

Checklist

@cortlepp

Copy link
Copy Markdown
Contributor Author

@timtebeek currently this PR only contains a new (failing) tests, I didn't figure out how to tell ChangeType (or something else) to delete any final qualifier if it exists. This is the line that needs changing:

doAfterVisit(new ChangeType("org.junit.rules.TestName", "java.lang.String", true).getVisitor());

@cortlepp
cortlepp force-pushed the fix/test-rule-final branch from 940c046 to dbaf1e1 Compare August 26, 2026 10:45
@timtebeek
timtebeek marked this pull request as draft August 26, 2026 10:53
The generated `@BeforeEach` assigns the field, which does not compile if the
original `@Rule` field was declared `final`.
@cortlepp

Copy link
Copy Markdown
Contributor Author

Thanks @timtebeek ! The fix was more complicated than I thought it would be after all.

@timtebeek
timtebeek marked this pull request as ready for review August 26, 2026 11:28
@timtebeek
timtebeek merged commit 4a83094 into openrewrite:main Aug 26, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Aug 26, 2026
@timtebeek

Copy link
Copy Markdown
Member

No worries, thanks for flagging it here! Glad we could help you out quickly.

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