首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么IntelliJ不能识别我的Spek测试?

为什么IntelliJ不能识别我的Spek测试?
EN

Stack Overflow用户
提问于 2017-01-31 07:13:41
回答 2查看 3.5K关注 0票数 11

我有一个基于Gradle的Kotlin项目,带有一些斯派克测试,这些测试基于JUnit,应该与Idea兼容。

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

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

这是我的build.gradle

代码语言:javascript
复制
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(' ')
    }
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-31 10:04:18

您安装了用于IntelliJ的Spek插件吗?

只需在spek插件设置中搜索IntelliJ。

票数 11
EN

Stack Overflow用户

发布于 2017-07-08 15:25:38

由于您使用的是Junit 4.11,所以可以从build.gradle中删除它:

代码语言:javascript
复制
junitPlatform {
    filters {
        engines {
            include 'spek'
        }
    }
}

然后在测试类声明中添加以下内容:

代码语言:javascript
复制
@RunWith(JUnitPlatform::class)

来源:http://spekframework.org/docs/latest/#setting-up-legacy

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41951683

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档