25
25
import org .gradle .api .tasks .testing .junitplatform .JUnitPlatformOptions ;
26
26
import org .gradle .testretry .TestRetryPlugin ;
27
27
import org .gradle .testretry .TestRetryTaskExtension ;
28
- import org .jetbrains .kotlin .gradle .targets .jvm .tasks .KotlinJvmTest ;
29
28
30
29
import java .util .Map ;
31
30
36
35
* <li>The {@link TestRetryPlugin Test Retry} plugin is applied so that flaky tests
37
36
* are retried 3 times when running on the CI server.
38
37
* <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.
40
39
* </ul>
41
40
*
42
41
* @author Brian Clozel
@@ -50,7 +49,7 @@ void apply(Project project) {
50
49
}
51
50
52
51
private void configureTestConventions (Project project ) {
53
- configureMockitoAgent (project );
52
+ configureByteBuddyAgent (project );
54
53
project .getTasks ().withType (Test .class ,
55
54
test -> {
56
55
configureTests (project , test );
@@ -81,20 +80,16 @@ private void configureTests(Project project, Test test) {
81
80
);
82
81
}
83
82
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 );
91
90
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 ()));
98
93
});
99
94
}
100
95
}
0 commit comments