EqualsVerifier 2.x requires Java 7 or higher. EqualsVerifier 1.x requires Java 6 or higher.
Add this to your POM:
Please adjust for your build system of choice.
Also, if you need to download the jar file directly, you can download it from maven.org. EqualsVerifier doesn’t have any transitive dependencies, so this jar is all you need.
Use it in a test
This is what EqualsVerfier can look like in your test:
Chances are, EqualsVerifier will give you an error message on the first try. That might be frustrating at first, but there’s a good reason for it. There’s a surprising number of ways in which an
equals method can contain bugs. Even when you let your IDE generate it, it might have problems.
These problems might not seem like a big deal, and to be honest, you might never encounter them anyway. But if you do, they can be incredibly hard to debug.
That’s why EqualsVerifier’s philosophy is to be super-strict by default. In fact, it can be frustratingly strict. But there’s a lot of ways to tweak EqualsVerifier to make it behave just the way you want it to.
Here are the most common issues you might run into on your first try: