I have a Gradle-based Kotlin project with some Spek tests, which are based on JUnit and should be compatible with Idea.
But I don't see a "Run" menu item in the context menu.
Why? What do I need to do in order to be able to run Spek tests in Idea like other JUnit tests?
Here's my build.gradle
:
buildscript {
ext.kotlin_version = '1.0.4'
repositories {
mavenCentral()
maven {
url "https://dl.bintray.com/jetbrains/spek"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M3'
}
}
apply plugin: "kotlin"
apply plugin: "application"
apply plugin: 'org.junit.platform.gradle.plugin'
junitPlatform {
filters {
engines {
include 'spek'
}
}
}
mainClassName = "com.mycompany.myproduct.AppKt"
sourceSets {
deploy
}
repositories {
mavenCentral()
maven {
url "https://dl.bintray.com/jetbrains/spek"
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'org.telegram:telegrambots:2.4.2'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
compile group: 'ch.qos.logback', name: 'logback-core', version: '1.1.3'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.3'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.6.1'
testCompile 'junit:junit:4.11'
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testCompile group: 'org.mockito', name: 'mockito-all', version: '2.0.2-beta'
testCompile 'org.jetbrains.spek:spek-api:1.1.19'
testRuntime 'org.jetbrains.spek:spek-junit-platform-engine:1.1.19'
}
test.testClassesDir = project.tasks.compileTestKotlin.destinationDir
task wrapper(type: Wrapper) {
gradleVersion="3.1"
}
run {
jvmArgs = ["-Xmx100m", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/[...]/log/memdump.log"]
}
jar {
manifest {
attributes 'Main-Class': mainClassName,
'Class-Path': configurations.runtime.files.collect {"$it.name"}.join(' ')
}
}
Check in Project settings -> Modules that you test package is marked as Tests. Right click on the test class name either in the code window or in the project panel, and select Run <classname>. If you don't see the run menu in the popup then you haven't selected a test or you don't have junit plugin installed.
Have you installed the Spek plugin for IntelliJ?
Just search for spek
in the IntelliJ plugin settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With