mirror of https://github.com/usbharu/Hideout.git
test: equalsとtostringでカバレッジ計測時に無視できるようなテストを追加(テストを目的としていない)
This commit is contained in:
parent
3ec6ace113
commit
66fb3c3c93
|
@ -32,6 +32,11 @@ tasks.withType<Test> {
|
||||||
val cpus = Runtime.getRuntime().availableProcessors()
|
val cpus = Runtime.getRuntime().availableProcessors()
|
||||||
maxParallelForks = max(1, cpus - 1)
|
maxParallelForks = max(1, cpus - 1)
|
||||||
setForkEvery(4)
|
setForkEvery(4)
|
||||||
|
doFirst {
|
||||||
|
jvmArgs = arrayOf(
|
||||||
|
"--add-opens", "java.base/java.lang=ALL-UNNAMED"
|
||||||
|
).toMutableList()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>().configureEach {
|
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>().configureEach {
|
||||||
|
@ -160,7 +165,8 @@ dependencies {
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
|
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
|
||||||
testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0")
|
testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0")
|
||||||
testImplementation("org.mockito:mockito-inline:5.2.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-core:0.6.0")
|
||||||
implementation("org.drewcarlson:kjob-mongo:0.6.0")
|
implementation("org.drewcarlson:kjob-mongo:0.6.0")
|
||||||
|
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue