문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 마지막 판 양쪽 다음 판 | ||
java:equals_verifier [2014/07/08 16:13] kwon37xi |
java:equals_verifier [2018/05/02 10:44] kwon37xi [Equals Verifier] |
||
---|---|---|---|
줄 3: | 줄 3: | ||
* Java 클래스의 '' | * Java 클래스의 '' | ||
* 이름은 '' | * 이름은 '' | ||
+ | * 테스트를 실행했는데 오류가 발생하면 http:// | ||
+ | |||
===== Lombok equals hashCode 테스트 ===== | ===== Lombok equals hashCode 테스트 ===== | ||
* '' | * '' | ||
@Test | @Test | ||
- | public void equalsContract() throws Exception { | + | public void equalsAndHashCodeContract() throws Exception { |
class SubEqualsVerifierExample extends EqualsVerifierExample { | class SubEqualsVerifierExample extends EqualsVerifierExample { | ||
@Override | @Override | ||
줄 14: | 줄 16: | ||
} | } | ||
} | } | ||
- | EqualsVerifier.forClass(EqualsVerifierExample.class).suppress(Warning.NONFINAL_FIELDS).withRedefinedSubclass(SubEqualsVerifierExample.class).verify(); | + | EqualsVerifier.forClass(EqualsVerifierExample.class) |
+ | | ||
+ | | ||
+ | | ||
} | } | ||
</ | </ | ||
+ | * 커버리지가 낮게 나오면 '' | ||
+ | |||
+ | ===== IntelliJ Live Template ===== | ||
+ | ==== java ==== | ||
+ | <code java> | ||
+ | class Sub$CLASS$ extends $CLASS$ { | ||
+ | @Override | ||
+ | public boolean canEqual(Object obj) { | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | EqualsVerifier.forClass($CLASS$.class) | ||
+ | .suppress(Warning.NULL_FIELDS, | ||
+ | .withRedefinedSubclass(Sub$CLASS$.class) | ||
+ | .verify(); | ||
+ | </ | ||
+ | * Applicable in Java: statement | ||
+ | * Reformat according to style : check | ||
+ | * Use static import if possible : check | ||
+ | * Short FQ names : check | ||
+ | |||
+ | ==== Groovy Spock ==== | ||
+ | <code groovy> | ||
+ | static class Sub$CLASS$ extends $CLASS$ { | ||
+ | @Override | ||
+ | boolean canEqual(Object obj) { | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | def " | ||
+ | expect: | ||
+ | EqualsVerifier.forClass($CLASS$.class) | ||
+ | .suppress(nl.jqno.equalsverifier.Warning.NONFINAL_FIELDS, | ||
+ | .withRedefinedSubclass(Sub$CLASS$.class) | ||
+ | .withRedefinedSuperclass() | ||
+ | .verify(); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | * Applicable in Spock Specification | ||
+ | * Reformat according to style : check | ||
+ | * Use static import if possible : check | ||
+ | * Short FQ names : check |