https://github.com/jqno/equalsverifier
EqualsVerifier can be used in Java unit tests to verify whether the contract for the equals and hashCode methods is met.
https://github.com/jqno/equalsverifier
equals java testing
Last synced: 26 days ago
JSON representation
EqualsVerifier can be used in Java unit tests to verify whether the contract for the equals and hashCode methods is met.
- Host: GitHub
- URL: https://github.com/jqno/equalsverifier
- Owner: jqno
- License: apache-2.0
- Created: 2015-03-29T09:12:21.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2026-02-16T19:45:21.000Z (about 1 month ago)
- Last Synced: 2026-02-16T20:58:09.417Z (about 1 month ago)
- Topics: equals, java, testing
- Language: Java
- Homepage: http://www.jqno.nl/equalsverifier
- Size: 9.26 MB
- Stars: 734
- Watchers: 19
- Forks: 87
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-java - EqualsVerifier
README
# EqualsVerifier
[](https://github.com/jqno/equalsverifier/actions)
[](https://isitmaintained.com/project/jqno/equalsverifier "Average time to resolve an issue")
[](https://github.com/jqno/equalsverifier/blob/master/LICENSE.md)
[](https://maven-badges.herokuapp.com/maven-central/nl.jqno.equalsverifier/equalsverifier/)
[](https://javadoc.io/doc/nl.jqno.equalsverifier/equalsverifier)
**EqualsVerifier** can be used in Java unit tests to verify whether the contract for the equals and hashCode methods in a class is met.
# Getting Started
EqualsVerifier's Maven coordinates are:
```xml
nl.jqno.equalsverifier
equalsverifier
4.4
test
```
(Note that there's also a 'fat' jar with no transitive dependencies with artifactId `equalsverifier-nodep`.)
Now you can write a test:
```java
import nl.jqno.equalsverifier.*;
@Test
public void equalsContract() {
EqualsVerifier.forClass(Foo.class).verify();
}
```
EqualsVerifier is an opinionated library, which means that it can be quite strict. If you feel it's too much, you can make it more lenient:
```java
import nl.jqno.equalsverifier.*;
@Test
public void equalsContract() {
EqualsVerifier.simple().forClass(Foo.class).verify();
}
```
This way, EqualsVerifier will throw less errors at you. However, it's usually better to just fix the errors: EqualsVerifier throws them for a reason!
## Prefer to watch a short video?
[](http://www.youtube.com/watch?v=ivRjf8yvVMk "Video Title")
Video by [Tom Cools](https://twitter.com/TCoolsIT)
## Documentation
For more documentation, see:
- The [code of conduct](CODE_OF_CONDUCT.md)
- The [contribution guidelines](CONTRIBUTING.md) file
- The [changelog](https://github.com/jqno/equalsverifier/blob/main/CHANGELOG.md)
- The [project's website](https://jqno.nl/equalsverifier/)
# A note on equality
EqualsVerifier cares about bug-free equality, in Java and in real life. The place where a person happens to be born, the colour of their skin, their gender, or the person they happen to love, must not affect the way they are treated in life. If it does, that's a bug and it should throw an error.
Don't allow bugs in your equality.
ππ§π»βπ€βπ§πΎπ
# Contribution
Pull requests are welcome! If you plan to open one, please also [register an issue](https://github.com/jqno/equalsverifier/issues/new) or [start a discussion](https://github.com/jqno/equalsverifier/discussions/new/choose), so we can discuss it first. It would be a shame to put in a lot of work on something that isn't a good fit for the project. Also, I can help you by giving pointers on where to find certain things.
# Disclaimer
Copyright 2009-2025 Jan Ouwens