@@ -3,6 +3,10 @@ plugins {
3
3
// https://docs.gradle.org/current/userguide/java_library_plugin.html
4
4
`java- library`
5
5
6
+ // for managing custom test suite
7
+ // https://docs.gradle.org/current/userguide/jvm_test_suite_plugin.html
8
+ `jvm- test- suite`
9
+
6
10
// coverage, jacoco can cover kotlin codes
7
11
// https://docs.gradle.org/current/userguide/jacoco_plugin.html
8
12
jacoco
@@ -48,35 +52,50 @@ tasks.javadoc {
48
52
}
49
53
}
50
54
51
- tasks.named<Test >(" test" ) {
52
- useJUnitPlatform()
53
- maxParallelForks = Runtime .getRuntime().availableProcessors()
54
- }
55
-
56
- sourceSets {
57
- create(" integrationTest" ) {
58
- compileClasspath + = sourceSets.main.get().output
59
- runtimeClasspath + = sourceSets.main.get().output
55
+ testing {
56
+ suites {
57
+ // reference to test task which is automatically created
58
+ val test by getting(JvmTestSuite ::class ) {
59
+ targets {
60
+ all {
61
+ testTask.configure {
62
+ useJUnitPlatform()
63
+ maxParallelForks = Runtime .getRuntime().availableProcessors()
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ register<JvmTestSuite >(" integrationTest" ) {
70
+ dependencies {
71
+ // add dependency of project itself
72
+ implementation(project())
73
+ }
74
+
75
+ targets {
76
+ all {
77
+ testTask.configure {
78
+ // run after 'test' task
79
+ shouldRunAfter(test)
80
+
81
+ useJUnitPlatform()
82
+ maxParallelForks = Runtime .getRuntime().availableProcessors()
83
+ }
84
+ }
85
+ }
86
+ }
60
87
}
61
88
}
89
+
90
+ // configure dependencies integrationTest from project itself
91
+ // see also: https://github.com/gradle/gradle/issues/19870
62
92
val integrationTestImplementation: Configuration by configurations.getting {
63
93
extendsFrom(configurations.implementation.get(), configurations.testImplementation.get())
64
94
}
65
95
val integrationTestRuntimeOnly: Configuration by configurations.getting {
66
96
extendsFrom(configurations.runtimeOnly.get(), configurations.testRuntimeOnly.get())
67
97
}
68
98
69
- tasks.register<Test >(" integrationTest" ) {
70
- // run after 'test' task
71
- shouldRunAfter(" test" )
72
-
73
- useJUnitPlatform()
74
- maxParallelForks = Runtime .getRuntime().availableProcessors()
75
-
76
- testClassesDirs = sourceSets[" integrationTest" ].output.classesDirs
77
- classpath = sourceSets[" integrationTest" ].runtimeClasspath
78
- }
79
-
80
99
81
100
/* jacoco */
82
101
0 commit comments