Skip to content

Commit d47f114

Browse files
committed
#919 Explicit setup for Mockito inline mocking
1 parent 6aac8bd commit d47f114

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ java {
7474

7575
configurations {
7676
asciidoctorExt
77+
mockitoAgent
7778
}
7879

7980
dependencies {
@@ -89,6 +90,10 @@ dependencies {
8990

9091
testImplementation platform(testLibs.mockito.bom)
9192
testImplementation testLibs.bundles.mockito
93+
mockitoAgent platform(testLibs.mockito.bom)
94+
mockitoAgent(testLibs.mockito.core) {
95+
transitive = false
96+
}
9297

9398
testImplementation testLibs.awaitility
9499
// A lot (if not all) tests for jaybird-native are in the main project given dependencies on test infrastructure
@@ -212,6 +217,11 @@ test {
212217
println "Running tests for type ${project.'test.gds_type'}"
213218
// Use junit platform for unit tests
214219
useJUnitPlatform()
220+
jvmArgumentProviders.add(
221+
objects.newInstance(JavaAgentProvider).tap {
222+
agent = configurations.mockitoAgent.asPath
223+
}
224+
)
215225

216226
// Test configuration, defaults specified in gradle.properties (modify through ext, or use -P<prop>=<value>)
217227
systemProperties(

buildSrc/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-FileCopyrightText: Copyright 2026 Mark Rotteveel
2+
// SPDX-License-Identifier: LGPL-2.1-or-later
3+
plugins {
4+
id 'groovy-gradle-plugin'
5+
}
6+
7+
repositories {
8+
gradlePluginPortal()
9+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-FileCopyrightText: Copyright 2026 Mark Rotteveel
2+
// SPDX-License-Identifier: LGPL-2.1-or-later
3+
import org.gradle.api.provider.Property
4+
import org.gradle.api.tasks.InputFile
5+
import org.gradle.api.tasks.PathSensitive
6+
import org.gradle.api.tasks.PathSensitivity
7+
import org.gradle.process.CommandLineArgumentProvider
8+
9+
/**
10+
* Provider for {@code -javaagent:some.jar} command line arguments.
11+
*/
12+
abstract class JavaAgentProvider implements CommandLineArgumentProvider {
13+
14+
@InputFile
15+
@PathSensitive(PathSensitivity.RELATIVE)
16+
abstract Property<String> getAgent()
17+
18+
@Override
19+
Iterable<String> asArguments() {
20+
["-javaagent:${agent.get()}"]
21+
}
22+
23+
}

0 commit comments

Comments
 (0)