dfa1 / equalsverifier

EqualsVerifier can be used in Java unit tests to verify whether the contract for the equals and hashCode methods is met.

Home Page:http://www.jqno.nl/equalsverifier

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apache License 2.0 Maven Central Javadoc

Build Status SemVer stability Issue resolution

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.8.1</version>
    <scope>test</scope>
</dependency>

Documentation

Please see the project's website.

Contribution

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.

Development

Build

To build EqualsVerifier, you need Maven. Just call mvn from the command-line, without any parameters, and you're done. Alternatively, you can use any IDE with Maven support.

Formatting

EqualsVerifier uses Prettier-Java through Spotless to format Java files. You can call it using mvn (without any parameters), which will also run the tests and all the other static analysis. Or run mvn spotless:apply to only run the formatter.

Conditional tests

The src/test folder contains, apart from the regular java folder, some version-specific javaXX folders that target specific JDKs. For instance, the src/test/java16 folder contains unit tests that test things related to records. A Maven profile automatically picks up these folders if the JDK that runs the tests has at least that version. nl.jqno.equalsverifier.internal.architecture.TestPresenceTest checks that the tests are indeed picked up when the JDK version matches.

Signed JAR

The lib/ folder contains a 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=lib

The signed JAR itself can be found in this repo.

Disclaimer

Copyright 2009-2020 Jan Ouwens

About

EqualsVerifier can be used in Java unit tests to verify whether the contract for the equals and hashCode methods is met.

http://www.jqno.nl/equalsverifier

License:Apache License 2.0


Languages

Language:Java 100.0%