add Mockito

This commit is contained in:
Daniel Langbein 2025-01-21 13:12:05 +00:00
parent 9a6359d576
commit e631d5161e
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
2 changed files with 23 additions and 11 deletions

View File

@ -18,6 +18,7 @@ repositories {
}
val latestJmhVersion = "1.37"
val mockitoAgent = configurations.create("mockitoAgent")
dependencies {
// Use JUnit Jupiter for testing.
@ -27,6 +28,11 @@ dependencies {
// Required to use the IntelliJ plugin "JMH Java Microbenchmark Harness".
// https://stackoverflow.com/a/71286156/6334421
jmhAnnotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:$latestJmhVersion")
// Use Mockito for mocking.
// https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#mockito-instrumentation
testImplementation(libs.mockito)
mockitoAgent(libs.mockito) { isTransitive = false }
}
// Apply a specific Java toolchain to ease working on different environments.
@ -60,15 +66,21 @@ tasks.register<JavaExec>("runCbmCompetition") {
mainClass = "de.uni_marburg.powersort.benchmark.CbmCompetition"
}
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
tasks {
test {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
reports {
// XML reports for GitLab CI.
junitXml.required.set(true)
// HTML reports to view with a webbrowser.
html.required.set(true)
reports {
// XML reports for GitLab CI.
junitXml.required.set(true)
// HTML reports to view with a webbrowser.
html.required.set(true)
}
// Mockito JDK21+ config
// https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#mockito-instrumentation
jvmArgs("-javaagent:${mockitoAgent.asPath}")
}
}

View File

@ -2,9 +2,9 @@
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
[versions]
guava = "32.1.3-jre"
junit-jupiter = "5.10.1"
junit-jupiter = "5.10.3"
mockito = "5.14.0"
[libraries]
guava = { module = "com.google.guava:guava", version.ref = "guava" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" }