我有一个基于Gradle的Kotlin项目,包含大约Spek个测试,它们基于JUnit,应该与IDEA兼容.

But I don't see a "Run" menu item in the context menu.

Context menu

为什么?我需要做什么才能像其他JUnit测试一样在IDEA中运行Spek测试?

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(' ')
    }
}

推荐答案

Have you installed the Spek plugin for IntelliJ?

Just search for spek in the IntelliJ plugin settings.

Kotlin相关问答推荐

如何创建继承抽象的匿名对象的新实例?

如果启用了Flyway迁移,则不能具有配置属性';datources.default.架构-生成

我可以在kotlin/java.util.scanner中跳过分隔符而不重复吗?

为什么不';Kotlin是否在数据类构造函数中隐式分配null值可为null的字段?

Kotlin中是否可以混合使用推断和显式的通用类型参数?

如何在 Spring Boot 3 中为内部类提供运行时提示

如何为 Kotlin 中的每个循环设置以避免越界异常

JavaFX - 你如何在 Kotlin 中使用 MapValueFactory?

使用 Kotlin 协程时 Room dao 类出错

内联函数导致单元测试代码覆盖率报告出错

如何为你的 Flutter 元素添加 Kotlin 支持?

SpringBoot 2.5.0 对于 Jackson Kotlin 类的支持,请在类路径中添加com.fasterxml.jackson.module: jackson-module-kotlin

禁用 Android 12 默认启动画面

如何禁用智能投射突出显示 Kotlin?

IntentService (kotlin) 的默认构造函数

Map.mapTo 到另一个map

如何从 Firestore 查询中排除元素?

从代码块执行和返回(在 Elvis 运算符之后)

Kotlin get字段注释始终为空

如何在使用Koin DI的活动之间共享同一个ViewModel实例?