Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use EqualsVerifier to ensure that equals has been implemented correctly #320

Merged
merged 1 commit into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.hm.hafner</groupId>
<artifactId>codingstyle</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>

<packaging>jar</packaging>

Expand Down Expand Up @@ -62,6 +62,7 @@
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>

<!-- Project Test Dependencies Configuration -->
<equalsverifier.version>3.5.5</equalsverifier.version>
<junit.version>5.7.1</junit.version>
<junit-platform-launcher.version>1.7.1</junit-platform-launcher.version>
<mockito.version>3.8.0</mockito.version>
Expand Down Expand Up @@ -103,7 +104,6 @@

<!-- Maven Surefire ArgLine -->
<argLine>-Djava.util.logging.config.file=logging.properties</argLine>

</properties>

<dependencyManagement>
Expand Down Expand Up @@ -144,6 +144,12 @@
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>${equalsverifier.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/edu/hm/hafner/util/FilteredLogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.junit.jupiter.api.Test;

import nl.jqno.equalsverifier.EqualsVerifier;

import static edu.hm.hafner.util.assertions.Assertions.*;

/**
Expand Down Expand Up @@ -125,4 +127,9 @@ void shouldManuallyUseSerializationHelpers() {

assertThat(restored).isEqualTo(serializable);
}

@Test
void shouldObeyEqualsContract() {
EqualsVerifier.simple().forClass(FilteredLog.class).verify();
}
}
10 changes: 10 additions & 0 deletions src/test/java/edu/hm/hafner/util/TreeStringBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import org.junit.jupiter.api.Test;

import nl.jqno.equalsverifier.EqualsVerifier;

import static org.assertj.core.api.Assertions.*;

/**
Expand Down Expand Up @@ -115,4 +117,12 @@ void shouldCreateRandomTreeStrings() {
assertThat(o.get(i)).hasToString(a.get(i));
}
}

@Test
void shouldObeyEqualsContract() {
EqualsVerifier.simple()
.withPrefabValues(TreeString.class, TreeString.valueOf("One"), TreeString.valueOf("Teo"))
.forClass(TreeString.class)
.verify();
}
}