Replace JUnit assertThat with Hamcrest

New rule to your toolbox:

Replace JUnit assertThat with Hamcrest

This new jSparrow release eliminates some obstacles for migrating to JUnit 5!

The JUnit Assert.assertThat method is deprecated. Its sole purpose is to forward the call to the MatcherAssert.assertThat defined in Hamcrest 1.3. Therefore, it is recommended to directly use the equivalent assertion defined in the third party Hamcrest library.

Since JUnit 5 contains no equivalent assertion for assertThat, this rule also eliminates an obstacle for migration to JUnit 5.

Here is a short transformation example of the new rule:

The following test class:

is transformed to:

This new rule brings jSparrow to a total of 94 automatic refactoring rules.

Find out more information in the Release Notes for jSparrow Eclipse and jSparrow Maven!

“Code teaches you how to face really big problems.” ― Jack Dorsey

Promotion pop-up

jSparrow 22% off promotion image