Inspectopedia
 
2024.3

JUnit assertion can be 'assertThat()' call

Warning
Code Style
New
Last modified: 03 December 2024

Reports calls to Assert.assertEquals(), Assert.assertTrue(), etc. methods which can be migrated to Hamcrest declarative style Assert.assertThat() calls.

For example:

A quick-fix is provided to perform the migration:

This inspection requires that the Hamcrest library is available on the classpath.

Use the Statically import matcher's methods option to specify if you want the quick-fix to statically import the Hamcrest matcher methods.