GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HamcrestMatcherToJUnit5: support Kotlin sources by timtebeek · Pull Request #1058 · openrewrite/rewrite-testing-frameworks

Conversation

@timtebeek

@timtebeek timtebeek commented Jul 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

HamcrestMatcherToJUnit5 threw "No JavaSourceFile parent found" on Kotlin test sources because it always used JavaTemplate; it now branches on K.CompilationUnit and applies a KotlinTemplate (via KotlinParser) for Kotlin sources. It uses a Kotlin-specific template variant where the Java form is invalid Kotlin (Collection.size() → .size) and fixes a latent unbalanced-paren typo in the containsString template that only the Kotlin parser rejected. Type attribution of the generated assertions relies on the upstream fix openrewrite/rewrite#8324 (KotlinTemplate attributes members selected on substituted placeholders), so it needs a rewrite snapshot ≥ 8.88.0 build 59. The only remaining manual attribution is the enclosing assertX(condition, reason) call, which Kotlin leaves untyped because JUnit's (…, String) and (…, Supplier) overloads are ambiguous when the reason is a substituted placeholder. Adds Kotlin tests covering equalTo, not, greaterThan, containsString, nullValue, collections, and reason arguments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@timtebeek
HamcrestMatcherToJUnit5: support Kotlin via KotlinTemplate branches
ec06332
@moderne-meeseeks moderne-meeseeks Bot added this to OpenRewrite Jul 23, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jul 23, 2026
timtebeek added 3 commits July 23, 2026 18:13
@timtebeek
Attribute Kotlin types after KotlinTemplate instead of relaxing valid…
1b802cb
…ation
@timtebeek
Explain immutableExecutionContext(false) in notEqualToKotlin test
a1c6d66
@timtebeek
Clarify why only Kotlin needs post-template type attribution
f1a5d0b
@timtebeek
timtebeek marked this pull request as draft July 24, 2026 10:24
@timtebeek timtebeek self-assigned this Jul 24, 2026
timtebeek
timtebeek commented Jul 24, 2026
View reviewed changes
Comment thread src/main/java/org/openrewrite/java/testing/hamcrest/HamcrestMatcherToJUnit5.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

timtebeek added 2 commits July 25, 2026 01:45
@timtebeek
Remove Kotlin type-attribution workaround now fixed upstream
310109e
rewrite#8324 (KotlinTemplate: attribute members selected on substituted
placeholders) attributes the synthesized member calls, which cascades to
the enclosing assertion, so the manual attributeTypes pass is no longer
needed.
@timtebeek
Keep minimal attribution for reason arg, unresolvable overload upstream
8ae8614
rewrite#8324 types members-on-placeholders and their enclosing calls, but
JUnit's assertX(condition, String) vs assertX(condition, Supplier) overloads
stay ambiguous when the reason is a substituted placeholder, leaving the call
untyped so the static import is dropped. Attribute just that enclosing call.
@timtebeek
timtebeek marked this pull request as ready for review July 25, 2026 07:04
@timtebeek timtebeek changed the title HamcrestMatcherToJUnit5: support Kotlin via KotlinTemplate branches HamcrestMatcherToJUnit5: support Kotlin sources Jul 25, 2026
@timtebeek
timtebeek merged commit b1bbe20 into main Jul 25, 2026
1 check passed

Uh oh!

There was an error while loading. Please reload this page.

@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Jul 25, 2026
@timtebeek
timtebeek deleted the tim/kotlin-hamcrest-to-junit5 branch July 25, 2026 07:06
mergify Bot added a commit to robfrank/linklift that referenced this pull request Aug 4, 2026
@mergify
chore(deps): bump org.openrewrite.recipe:rewrite-testing-frameworks f…
a81c26e
…rom 3.42.1 to 3.43.0 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-testing-frameworks](https://github.com/openrewrite/rewrite-testing-frameworks) from 3.42.1 to 3.43.0.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-testing-frameworks's releases](https://github.com/openrewrite/rewrite-testing-frameworks/releases).*

> 3.43.0
> ------
>
> What's Changed
> --------------
>
> * ReplaceInitMockToOpenMock: support Kotlin via KotlinTemplate branches by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-testing-frameworks#1055](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1055)
> * Set Develocity `projectId` to "openrewrite" by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1056](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1056)
> * Fix AssertThrowsOnLastStatement crash on unattributed argument types by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1059](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1059)
> * AssertTrueNegationToAssertFalse: support Kotlin via LST manipulation by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1057](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1057)
> * Fix Hamcrest not() unwrap crash when wrapping a bare value by [`@​Jammy-Louie`](https://github.com/Jammy-Louie) in [openrewrite/rewrite-testing-frameworks#1062](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1062)
> * Migrate TestNG SoftAssert to AssertJ SoftAssertions by [`@​juherr`](https://github.com/juherr) in [openrewrite/rewrite-testing-frameworks#1063](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1063)
> * Support Kotlin in three JUnit testing recipes (fix crashes/no-ops) by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1065](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1065)
> * Migrate TestNG Assertion (instance) to AssertJ by [`@​juherr`](https://github.com/juherr) in [openrewrite/rewrite-testing-frameworks#1064](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1064)
> * Leave AssertThrowsOnLastStatement arguments inline when their type can't be rendered by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1066](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1066)
> * HamcrestMatcherToJUnit5: support Kotlin sources by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1058](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1058)
> * Build and test on Java 25 with rewrite-java-25 by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1061](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1061)
> * MockitoWhenOnStaticToMockStatic: name unnamed `_` variable when reusing MockedStatic by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1060](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1060)
> * Simplify AssertJ `==` and `!=` assertions into one recipe by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1067](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1067)
> * Forward Code Genome Project publish credentials to `ci-gradle.yml` by [`@​jkschneider`](https://github.com/jkschneider) in [openrewrite/rewrite-testing-frameworks#1068](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1068)
>
> **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.42.1...v3.43.0>


Commits

* [`641258d`](openrewrite/rewrite-testing-frameworks@641258d) Forward Code Genome Project publish credentials to `ci-gradle.yml` ([#1068](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1068))
* [`2024ec4`](openrewrite/rewrite-testing-frameworks@2024ec4) Simplify AssertJ `==` and `!=` assertions into one recipe ([#1067](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1067))
* [`c9ebc4f`](openrewrite/rewrite-testing-frameworks@c9ebc4f) MockitoWhenOnStaticToMockStatic: name unnamed `_` variable when reusing Mocke...
* [`4534e08`](openrewrite/rewrite-testing-frameworks@4534e08) Build and test on Java 25 with rewrite-java-25 ([#1061](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1061))
* [`b1bbe20`](openrewrite/rewrite-testing-frameworks@b1bbe20) HamcrestMatcherToJUnit5: support Kotlin sources ([#1058](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1058))
* [`8cfaee5`](openrewrite/rewrite-testing-frameworks@8cfaee5) Leave AssertThrowsOnLastStatement arguments inline when their type can't be r...
* [`acfa18f`](openrewrite/rewrite-testing-frameworks@acfa18f) Migrate TestNG Assertion (instance) to AssertJ ([#1064](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1064))
* [`5fe4cad`](openrewrite/rewrite-testing-frameworks@5fe4cad) Support Kotlin in three JUnit testing recipes (fix crashes/no-ops) ([#1065](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1065))
* [`d713402`](openrewrite/rewrite-testing-frameworks@d713402) feat: migrate TestNG SoftAssert to AssertJ SoftAssertions ([#1063](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1063))
* [`7ee9a16`](openrewrite/rewrite-testing-frameworks@7ee9a16) Fix Hamcrest not() unwrap crash when wrapping a bare value ([#1062](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1062))
* Additional commits viewable in [compare view](openrewrite/rewrite-testing-frameworks@v3.42.1...v3.43.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-testing-frameworks&package-manager=maven&previous-version=3.42.1&new-version=3.43.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@timtebeek timtebeek

Labels

None yet

Projects

OpenRewrite
Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@timtebeek
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.