EqualsVerifier can be used in Java unit tests to verify whether the contract for the equals and hashCode methods in a class is met. The Maven coordinates are:
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.1.5</version>
<scope>test</scope>
</dependency>For documentation, please see the project's website.
Pull requests are welcome! If you open one, please also register an issue or send a message to the Google Group, so we can discuss it.
To build EqualsVerifier, you need Maven. Just call mvn clean verify from the command-line, and you're done. Alternatively, you can use any IDE with Maven support.
src/
nl.jqno.equalsverifierExternal APInl.jqno.equalsverifier.internalClasses internal to the operation of EqualsVerifiernl.jqno.equalsverifier.internal.checkersCheckers that perform EqualsVerifier's actual verificationsnl.jqno.equalsverifier.internal.exceptionsInternally used exceptionsnl.jqno.equalsverifier.internal.prefabvaluesCache and factories for instances of all typesnl.jqno.equalsverifier.internal.reflectionHelpers for reflection-based tasksnl.jqno.equalsverifier.internal.utilVarious helpers
test/
javax.persistenceAnnotations used by integration testsnl.jqno.equalsverifierUnit tests for specific subcomponents of EqualsVerifiernl.jqno.equalsverifier.coverageCode coverage tests, which fail if coverage is less than 100%nl.jqno.equalsverifier.integration.basic_contractIntegration tests that cover the contract as stated injava.lang.Object's javadocnl.jqno.equalsverifier.integration.extended_contractIntegration tests that cover specific corner cases in the Java language, and other essential points that are discussed in other sources, such as Effective Java, but not in the javadocnl.jqno.equalsverifier.integration.extra_featuresIntegration tests that cover non-standard situations that EqualsVerifier supportsnl.jqno.equalsverifier.integration.inheritanceIntegration tests that cover inheritance in equality relationsnl.jqno.equalsverifier.integration.operationalIntegration tests that cover issues that don't pertain to equals or hashCode themselves, but to EqualsVerifier's operationnl.jqno.equalsverifier.testhelpersUtility classes for use in testsnl.jqno.equalsverifier.testhelpers.annotationsAnnotations used by unit tests and integration testsnl.jqno.equalsverifier.testhelpers.annotations.casefoldingMore annotations which would clash with other annotations because of casingnl.jqno.equalsverifier.testhelpers.typesVarious data classes for use in unit tests and integration testsnl.jqno.equalsverifier.utilUnit tests for the reflection helpers
lib/
equalsverifier-signedjar-test.jarA local Maven repository containing a signed jar, used to test potential ClassLoader issues
Here's how to install a jar into it:
mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file \ -Dfile=<path-to-file> -DgroupId=<myGroup> \ -DartifactId=<myArtifactId> -Dversion=<myVersion> \ -Dpackaging=<myPackaging> -DcreateChecksum=true \ -DlocalRepositoryPath=libThe signed jar itself can be found in this repo.
Copyright 2009-2017 Jan Ouwens