[FEATURE] Replace JUnit assertEquals() with Hamcrest matchers assertThat() #3680
Labels
enhancement
New feature or request
triaged
Issues labeled as 'Triaged' have been reviewed and are deemed actionable.
Is your feature request related to a problem?
It is recommended to replace Assert.assertEquals() with assertThat() for a greater degree of verbosity and readability as seen in issue #1832 . But as of November 2023 there're a little less than 3k instances that need to be replaced. I've made some attempts as seen in #3500 and #3443 but after replacing more than half cases and running into a few issues with new updates to main, perhaps a new take on this issue would make for a good first issue.
What solution would you like?
Replacing all JUnit
assertEquals(expected, actual)
with HamcrestassertThat(actual, is(expected))
Based on my experience I would suggest:
Note* After running the regex and saving the output as the original file name with
mv outputfile.java inputfile.java
you might have to then go the outputfile and edit any instances ofAssert.assertThat()
toassertThat()
using a simple replace command in your editor. Also make sure to add imports for each file (as seen below) or create a higher order import:What alternatives have you considered?
As for alternatives to this issue itself, this change isn't really that necessary as it's mainly focused helping with debugging. One could argue that this feature isn't as useful but it could make for a good first PR, albeit a bit tedious.
Do you have any additional context?
As mentioned earlier, I don't think this issue presents too much significance outside the added readability/debugging but it could be something to do or I could simply be mistaken.
Best of luck :)
The text was updated successfully, but these errors were encountered: