@@ -23,19 +23,48 @@ repositories {
23
23
mavenCentral()
24
24
}
25
25
26
- sourceSets {
27
- val main = main.get()
28
- val dev = create(" dev" ) {
29
- compileClasspath + = main.output
30
- runtimeClasspath + = main.output
31
- }
32
- test {
33
- compileClasspath + = dev.output
34
- runtimeClasspath + = dev.output
35
- }
36
- create(" testIntegration" ) {
37
- compileClasspath + = main.output + test.get().output + dev.output
38
- runtimeClasspath + = main.output + test.get().output + dev.output
26
+ val devSourceSet = sourceSets.create(" dev" ) {
27
+ val main = sourceSets.main.get()
28
+ compileClasspath + = main.output
29
+ runtimeClasspath + = main.output
30
+ }
31
+
32
+ lateinit var testIntegration: NamedDomainObjectProvider <JvmTestSuite >
33
+ testing {
34
+ suites {
35
+ val test by getting(JvmTestSuite ::class )
36
+ testIntegration = register<JvmTestSuite >(" testIntegration" ) {
37
+ dependencies {
38
+ implementation(project())
39
+ implementation(sourceSets.test.get().output)
40
+ }
41
+ targets {
42
+ all {
43
+ testTask.configure {
44
+ shouldRunAfter(test)
45
+ }
46
+ }
47
+ }
48
+ }
49
+ withType<JvmTestSuite > {
50
+ useJUnitJupiter()
51
+
52
+ dependencies {
53
+ // testing
54
+ implementation(tests.junit.api)
55
+ runtimeOnly(tests.junit.engine)
56
+ runtimeOnly(tests.junit.launcher)
57
+ implementation(tests.ktor.server.tests)
58
+ implementation(tests.mockk)
59
+ implementation(tests.assertj.core)
60
+ implementation(tests.json)
61
+ implementation(tests.h2)
62
+ implementation(tests.testcontainers)
63
+ implementation(tests.testcontainers.junit)
64
+ implementation(tests.testcontainers.keycloak)
65
+ implementation(devSourceSet.output)
66
+ }
67
+ }
39
68
}
40
69
}
41
70
@@ -99,19 +128,6 @@ dependencies {
99
128
// task scheduling
100
129
implementation(libraries.jobrunr)
101
130
102
- // testing
103
- testImplementation(tests.junit.api)
104
- testRuntimeOnly(tests.junit.engine)
105
- testRuntimeOnly(tests.junit.launcher)
106
- testImplementation(tests.ktor.server.tests)
107
- testImplementation(tests.mockk)
108
- testImplementation(tests.assertj.core)
109
- testImplementation(tests.json)
110
- testImplementation(tests.h2)
111
- testImplementation(tests.testcontainers)
112
- testImplementation(tests.testcontainers.junit)
113
- testImplementation(tests.testcontainers.keycloak)
114
-
115
131
// dev
116
132
devImplementation(dev.keycloak.adminClient)
117
133
}
@@ -122,36 +138,17 @@ application {
122
138
if (isDevelopment) {
123
139
applicationDefaultJvmArgs + = " -Dio.ktor.development=$isDevelopment "
124
140
tasks.run.configure {
125
- classpath + = sourceSets[ " dev " ] .output
141
+ classpath + = devSourceSet .output
126
142
}
127
143
}
128
144
}
129
145
130
146
tasks.test {
131
147
jvmArgs(" -Dio.ktor.development=true" )
132
- useJUnitPlatform()
133
- }
134
-
135
- val integrationTest: SourceSet = sourceSets[" testIntegration" ]
136
-
137
-
138
- configurations[integrationTest.implementationConfigurationName].extendsFrom(configurations.testImplementation.get())
139
- configurations[integrationTest.runtimeOnlyConfigurationName].extendsFrom(configurations.testRuntimeOnly.get())
140
-
141
- val integrationTestTask = tasks.register<Test >(" integrationTest" ) {
142
- group = " verification"
143
- description = " Runs tests against integrations (database, LMS, etc)"
144
-
145
- useJUnitPlatform()
146
-
147
- testClassesDirs = integrationTest.output.classesDirs
148
- classpath = integrationTest.runtimeClasspath
149
-
150
- shouldRunAfter(" test" )
151
148
}
152
149
153
150
tasks.check {
154
- dependsOn(integrationTestTask )
151
+ dependsOn(testIntegration )
155
152
}
156
153
157
154
buildInfo {
@@ -229,8 +226,6 @@ idea {
229
226
// long import times but worth it as, without it, functions may not have proper documentation
230
227
isDownloadJavadoc = true
231
228
isDownloadSources = true
232
- sourceDirs.minusAssign(file(" src/testIntegration" ))
233
- testSources.from(file(" src/testIntegration/kotlin" ))
234
229
}
235
230
236
231
project {
0 commit comments