У меня есть этот gradle-проект, в который я добавил два новых набора исходных текстов "acceptTest" и "grationTest ". Сначала я добавил «acceptTest», и он работает нормально, затем скопировал код, чтобы создать «интеграционный тест».
Когда я создаю файл в интегрированном тесте, я получаю «Kotlin не настроен» в IntelliJ. То же самое происходит, когда я пытаюсь запустить Gradle.
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.71'
}
apply plugin: 'idea'
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
jcenter()
}
configurations {
acceptanceTestCompile.extendsFrom testCompile
acceptanceTestRuntime.extendsFrom testRuntime
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
sourceSets {
acceptanceTest {
kotlin {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file("src/acceptanceTest/kotlin")
}
resources.srcDir file("src/acceptanceTest/resources")
}
kotlin {
}
integrationTest {
kotlin {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file("src/integrationTest/kotlin")
}
resources.srcDir file("src/integrationTest/resources")
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.yaml:snakeyaml:1.26"
testImplementation "org.junit.jupiter:junit-jupiter:5.6.1"
testImplementation "io.mockk:mockk:1.9.3.kotlin12"
testRuntimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testImplementation "org.assertj:assertj-core:3.11.1"
acceptanceTestRuntime "org.yaml:snakeyaml:1.26"
acceptanceTestImplementation "org.spekframework.spek2:spek-dsl-jvm:$spek_version"
acceptanceTestImplementation "org.spekframework.spek2:spek-runner-junit5:$spek_version"
acceptanceTestImplementation "org.assertj:assertj-core:3.11.1"
acceptanceTestImplementation "io.mockk:mockk:1.9.3.kotlin12"
}
task acceptanceTest(type: Test) {
testClassesDirs = sourceSets.acceptanceTest.output.classesDirs
classpath = sourceSets.acceptanceTest.runtimeClasspath
outputs.upToDateWhen { false }
}
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}
check.dependsOn integrationTest
integrationTest.mustRunAfter test
check.dependsOn acceptanceTest
acceptanceTest.mustRunAfter integrationTest
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
acceptanceTest {
useJUnitPlatform {
includeEngines 'spek2'
}
testLogging {
events("passed", "skipped", "failed")
}
}
integrationTest {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
idea {
module {
testSourceDirs += project.sourceSets.integrationTest.kotlin.srcDirs
testSourceDirs += project.sourceSets.integrationTest.resources.srcDirs
testSourceDirs += project.sourceSets.acceptanceTest.kotlin.srcDirs
testSourceDirs += project.sourceSets.acceptanceTest.resources.srcDirs
}
}