2525import org .gradle .api .tasks .testing .junitplatform .JUnitPlatformOptions ;
2626import org .gradle .testretry .TestRetryPlugin ;
2727import org .gradle .testretry .TestRetryTaskExtension ;
28- import org .jetbrains .kotlin .gradle .targets .jvm .tasks .KotlinJvmTest ;
2928
3029import java .util .Map ;
3130
3635 * <li>The {@link TestRetryPlugin Test Retry} plugin is applied so that flaky tests
3736 * are retried 3 times when running on the CI server.
3837 * <li>Common test properties are configured
39- * <li>The Mockito Java agent is set on test tasks.
38+ * <li>The ByteBuddy Java agent is configured on test tasks.
4039 * </ul>
4140 *
4241 * @author Brian Clozel
@@ -50,7 +49,7 @@ void apply(Project project) {
5049 }
5150
5251 private void configureTestConventions (Project project ) {
53- configureMockitoAgent (project );
52+ configureByteBuddyAgent (project );
5453 project .getTasks ().withType (Test .class ,
5554 test -> {
5655 configureTests (project , test );
@@ -81,20 +80,16 @@ private void configureTests(Project project, Test test) {
8180 );
8281 }
8382
84- private void configureMockitoAgent (Project project ) {
85- if (project .hasProperty ("mockitoVersion " )) {
86- String mockitoVersion = (String ) project .getProperties ().get ("mockitoVersion " );
87- Configuration mockitoAgentConfig = project .getConfigurations ().create ("mockitoAgent " );
88- mockitoAgentConfig .setTransitive (false );
89- Dependency mockitoCore = project .getDependencies ().create ("org.mockito:mockito-core :" + mockitoVersion );
90- mockitoAgentConfig .getDependencies ().add (mockitoCore );
83+ private void configureByteBuddyAgent (Project project ) {
84+ if (project .hasProperty ("byteBuddyVersion " )) {
85+ String byteBuddyVersion = (String ) project .getProperties ().get ("byteBuddyVersion " );
86+ Configuration byteBuddyAgentConfig = project .getConfigurations ().create ("byteBuddyAgentConfig " );
87+ byteBuddyAgentConfig .setTransitive (false );
88+ Dependency byteBuddyAgent = project .getDependencies ().create ("net.bytebuddy:byte-buddy-agent :" + byteBuddyVersion );
89+ byteBuddyAgentConfig .getDependencies ().add (byteBuddyAgent );
9190 project .afterEvaluate (p -> {
92- p .getTasks ().withType (Test .class , test -> test .jvmArgs ("-javaagent:" + mockitoAgentConfig .getAsPath ()));
93- project .getPlugins ().withId ("org.jetbrains.kotlin.jvm" , plugin -> {
94- project .getTasks ().withType (KotlinJvmTest .class , kotlinTest -> {
95- kotlinTest .jvmArgs ("-javaagent:" + mockitoAgentConfig .getAsPath ());
96- });
97- });
91+ p .getTasks ().withType (Test .class , test -> test
92+ .jvmArgs ("-javaagent:" + byteBuddyAgentConfig .getAsPath ()));
9893 });
9994 }
10095 }
0 commit comments