EqualsVerifier

Have you ever written an equals method, along with five screens of unit tests to test it? Or worse: not bothered to test it at all, because “the IDE generates it anyway”?

EqualsVerifier helps you. Testing equals can be as simple as:

@Test
public void equalsContract() {
    EqualsVerifier.forClass(Foo.class).verify();
}

And EqualsVerifier even gives you 100% coverage on equals and hashCode methods.

Sounds great, how do I use it?

Add it to your build like this (please adjust for your build system of choice):

<dependency>
    <groupId>nl.jqno.equalsverifier</groupId>
    <artifactId>equalsverifier</artifactId>
    <version>3.0.2</version>
    <scope>test</scope>
</dependency>
  • If you want to get started quickly, read the getting started page.
  • If you want to learn more, read the manual, or watch the video:

If you’re interested, there’s more to read:

Fork me on GitHub!

The source for this project is hosted on GitHub.

Pull Requests are welcome! But please also open an issue or send a message to the Google Group so we can discuss it.