add Mockito

This commit is contained in:
Daniel Langbein 2025-01-15 21:13:59 +01:00
parent c3d3f8356e
commit 6ce71738f2
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
2 changed files with 19 additions and 5 deletions

View File

@ -15,11 +15,17 @@ repositories {
mavenCentral()
}
val mockitoAgent = configurations.create("mockitoAgent")
dependencies {
// Use JUnit Jupiter for testing.
testImplementation(libs.junit.jupiter)
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// 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.
@ -34,7 +40,13 @@ application {
mainClass = "quality.software.Main"
}
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
tasks {
test {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
// Mockito JDK21+ config
// https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#mockito-instrumentation
jvmArgs("-javaagent:${mockitoAgent.asPath}")
}
}

View File

@ -4,7 +4,9 @@
[versions]
guava = "33.2.1-jre"
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" }