@@ -12,6 +12,11 @@ plugins {
1212 id(" junitbuild.build-parameters" )
1313}
1414
15+ var javaAgent = configurations.dependencyScope(" javaAgent" )
16+ var javaAgentClasspath = configurations.resolvable(" javaAgentClasspath" ) {
17+ extendsFrom(javaAgent.get())
18+ }
19+
1520var openTestReportingCli = configurations.dependencyScope(" openTestReportingCli" )
1621var openTestReportingCliClasspath = configurations.resolvable(" openTestReportingCliClasspath" ) {
1722 extendsFrom(openTestReportingCli.get())
@@ -117,6 +122,10 @@ tasks.withType<Test>().configureEach {
117122 )
118123 }
119124
125+ jvmArgumentProviders + = objects.newInstance(JavaAgentArgumentProvider ::class ).apply {
126+ classpath.from(javaAgentClasspath)
127+ }
128+
120129 val reportFiles = objects.fileTree().from(reports.junitXml.outputLocation).matching { include(" junit-platform-events-*.xml" ) }
121130 doFirst {
122131 reportFiles.files.forEach {
@@ -129,7 +138,7 @@ tasks.withType<Test>().configureEach {
129138
130139dependencies {
131140 testImplementation(dependencyFromLibs(" assertj" ))
132- testImplementation(dependencyFromLibs(" mockito" ))
141+ testImplementation(dependencyFromLibs(" mockito-junit-jupiter " ))
133142 testImplementation(dependencyFromLibs(" testingAnnotations" ))
134143 testImplementation(project(" :junit-jupiter" ))
135144
@@ -147,4 +156,17 @@ dependencies {
147156
148157 openTestReportingCli(dependencyFromLibs(" openTestReporting-cli" ))
149158 openTestReportingCli(project(" :junit-platform-reporting" ))
159+
160+ javaAgent(dependencyFromLibs(" mockito-core" )) {
161+ isTransitive = false
162+ }
163+ }
164+
165+ abstract class JavaAgentArgumentProvider : CommandLineArgumentProvider {
166+
167+ @get:Classpath
168+ abstract val classpath: ConfigurableFileCollection
169+
170+ override fun asArguments () = listOf (" -javaagent:${classpath.singleFile.absolutePath} " )
171+
150172}
0 commit comments