Open joel-costigliola opened 9 years ago
I did similar migration using bash script from Hamcrest to AssertJ in my commercial project with more than 16,000 different assertions. It's more advanced than the one from link, eg. it handles multi-line assertions without any problems and it converts about three times more different Hamcrest matchers, also without static imports.
I'm really willing to share my script after additional testing on other projects. @joel-costigliola, can you assign me to this issue?
16 000 assertions, impressive ! Your script would be a nice addition.
I can't assign the issue to you as you are not an admin of this project (I don' understand the rationale of this limitation), if you want to work on an issue just add a comment to say so.
OK, I'm taking it. The current version of my bash script uses perl
to execute regular expressions to match multiple lines. Sed has a lot of problems with it. Is this fine? Or maybe I should rewrite the script to e.g. Groovy?
Perl
is fine as long as the script is commented, otherwise I would python but it's just a matter of preferences.
Perl is just used to do multiline replacement in file, the rest is Bash. You can monitor the progress at https://github.com/mkordas/hamcrest-to-assertj
This comment is a little late to the party. I have created an IntelliJ plugin that can convert most JUnit and Hamcrest Assertions to AssertJ.
Assertions2Assertj - https://plugins.jetbrains.com/plugin/10345-assertions2assertj
Hopefully this will be of help to others.
@ricemery we will mention it in the website/doc, thanks for providing it!
I'll put a reference to @mkordas script in assertj website if we can solve https://github.com/mkordas/hamcrest-to-assertj/issues/2.
see : http://danhaywood.com/2015/04/17/converting-from-hamcrest-to-assertj/
Fix also the existing scripts as some regex are not correct