assertj / assertj

AssertJ is a library providing easy to use rich typed assertions
https://assertj.github.io/doc/
Apache License 2.0
2.64k stars 706 forks source link

Hamcrest to AssertJ conversion script #373

Open joel-costigliola opened 9 years ago

joel-costigliola commented 9 years ago

see : http://danhaywood.com/2015/04/17/converting-from-hamcrest-to-assertj/

Fix also the existing scripts as some regex are not correct

mkordas commented 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?

joel-costigliola commented 9 years ago

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.

mkordas commented 9 years ago

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?

joel-costigliola commented 9 years ago

Perl is fine as long as the script is commented, otherwise I would python but it's just a matter of preferences.

mkordas commented 9 years ago

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

ricemery commented 6 years ago

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.

joel-costigliola commented 6 years ago

@ricemery we will mention it in the website/doc, thanks for providing it!

https://github.com/joel-costigliola/assertj/issues/80

joel-costigliola commented 6 years ago

I'll put a reference to @mkordas script in assertj website if we can solve https://github.com/mkordas/hamcrest-to-assertj/issues/2.