加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 为什么IntelliJ Idea不能识别我的Spek测试?

发布时间:2020-12-14 06:03:32 所属栏目:Java 来源:网络整理
导读:我有一个基于Gradle的Kotlin项目,有一些 Spek测试,它们基于JUnit,应该与Idea兼容. 但是我没有在上下文菜单中看到“运行”菜单项. 为什么?为了能够像其他JUnit测试一样在Idea中运行Spek测试,我需要做什么? 这是我的build.gradle: buildscript { ext.kotlin
我有一个基于Gradle的Kotlin项目,有一些 Spek测试,它们基于JUnit,应该与Idea兼容.

但是我没有在上下文菜单中看到“运行”菜单项.

为什么?为了能够像其他JUnit测试一样在Idea中运行Spek测试,我需要做什么?

这是我的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(' ')
    }
}

解决方法

你安装了 Spek plugin for IntelliJ吗?

只需在IntelliJ插件设置中搜索spek即可.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读