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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate Hamcrest to JUnit 5 #343
base: main
Are you sure you want to change the base?
Migrate Hamcrest to JUnit 5 #343
Changes from 8 commits
4b2e427
e8ffbae
0bb2ffa
0947005
11d9fd2
cc4a929
bc1d5c8
e17fc29
76724ca
e360972
66473e8
cc581eb
0eb3887
7d11579
1730fbf
3525302
9357f7a
9e23d71
d75e50f
21d4728
5395d63
ff0e775
483fcb4
26a8646
93448e3
be54077
be57cfe
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this matcher is failing, but you can work around it by for now adopting:
You might need to match the three different MethodMatcher assertThat methods in a specific order with this
..
variant last, but at least that will get you going.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seemingly has something to do with matcherMethod being called on primitives, for example
equalTo(5)
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last argument in withTemplate is actually a varargs. So you could reduce this when opting for a
Object[] args
as seen here.rewrite-testing-frameworks/src/main/java/org/openrewrite/java/testing/cleanup/AssertTrueEqualsToAssertEquals.java
Lines 75 to 80 in f25ff0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than statically defining the various options here, we could also look at turning the
hamcrestMatcher
andtargetAssertion
into@Option
arguments to the recipe, such that we can configure this repeatedly from a declarative Yaml description file. We already do something similar for Mockito, except in thise case you'd be configuring this new recipe rather thanChangeMethodName
. Such an approach pull those replacements out of code and into configuration, which is typically easier to expand on, even locally, for our users.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the recipe will fail currently with any 3/4 method arguments, as the template hardcodes the expected number of arguments to two; Might be best to add tests for various amounts of arguments and work from there to repeatedly append
, #{any(java.lang.Object)}
as needed, as also seen here.rewrite-testing-frameworks/src/main/java/org/openrewrite/java/testing/cleanup/AssertTrueEqualsToAssertEquals.java
Lines 74 to 82 in f25ff0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do end up going for declarative yaml recipes for the various matcher-to-method replacements, then we will likely want to import yaml recipes and run those instead of this direct invocation. Here's an example.
rewrite-testing-frameworks/src/test/java/org/openrewrite/java/testing/mockito/AnyToNullableTest.java
Lines 36 to 39 in f25ff0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might also want to verify our use of
equalTo
with Strings and other primitives, just to be sure we don't inadvertently produce errors there.