diff --git a/build.gradle.kts b/build.gradle.kts index 1c96989a..b72caa33 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,6 +32,11 @@ tasks.withType { val cpus = Runtime.getRuntime().availableProcessors() maxParallelForks = max(1, cpus - 1) setForkEvery(4) + doFirst { + jvmArgs = arrayOf( + "--add-opens", "java.base/java.lang=ALL-UNNAMED" + ).toMutableList() + } } tasks.withType>().configureEach { @@ -160,7 +165,8 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter:5.8.1") testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") testImplementation("org.mockito:mockito-inline:5.2.0") - + testImplementation("nl.jqno.equalsverifier:equalsverifier:3.15.3") + testImplementation("com.jparams:to-string-verifier:1.4.8") implementation("org.drewcarlson:kjob-core:0.6.0") implementation("org.drewcarlson:kjob-mongo:0.6.0") diff --git a/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt b/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt new file mode 100644 index 00000000..62f68093 --- /dev/null +++ b/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt @@ -0,0 +1,42 @@ +package dev.usbharu.hideout + +import com.jparams.verifier.tostring.ToStringVerifier +import nl.jqno.equalsverifier.EqualsVerifier +import nl.jqno.equalsverifier.Warning +import nl.jqno.equalsverifier.internal.reflection.PackageScanner +import org.junit.jupiter.api.Test +import java.lang.reflect.Modifier +import kotlin.test.assertFails + +class EqualsAndToStringTest { + @Test + fun equalsTest() { + assertFails { + EqualsVerifier + .simple() + .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT) + .forPackage("dev.usbharu.hideout", true) + .verify() + } + } + + @Test + fun toStringTest() { + + PackageScanner.getClassesIn("dev.usbharu.hideout", null, true) + .filter { + it != null && !it.isEnum && !it.isInterface && !Modifier.isAbstract(it.modifiers) + } + .forEach { + try { + ToStringVerifier.forClass(it).verify() + } catch (e: AssertionError) { + println(it.name) + e.printStackTrace() + } catch (e: Exception) { + println(it.name) + e.printStackTrace() + } + } + } +}