목차

Equals Verifier

Lombok equals hashCode 테스트

IntelliJ Live Template

java

class Sub$CLASS$ extends $CLASS$ {
	@Override
	public boolean canEqual(Object obj) {
		return false;
	}
}
EqualsVerifier.forClass($CLASS$.class)
	.suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS)
	.withRedefinedSubclass(Sub$CLASS$.class)
	.verify();

Groovy Spock

static class Sub$CLASS$ extends $CLASS$ {
	@Override
	boolean canEqual(Object obj) {
		return false
	}
}
 
def "equalsAndHashCode verify"() {
	expect:
	EqualsVerifier.forClass($CLASS$.class)
		.suppress(nl.jqno.equalsverifier.Warning.NONFINAL_FIELDS, nl.jqno.equalsverifier.Warning.ALL_FIELDS_SHOULD_BE_USED)
		.withRedefinedSubclass(Sub$CLASS$.class)
		.withRedefinedSuperclass()
		.verify()
}