java - 错误 :(56, 0) 原因 : org. gradle.api.tasks.testing.Test_Decolated 无法转换为 java.lang.Class

标签 java groovy intellij-idea build gradle

我有这个build.gradle

apply plugin: 'java'

sourceCompatibility = 1.8
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
//
//    configurations.all*.exclude(group: 'com.sun.jersey', module: 'jersey-bundle')
//    configurations.all*.exclude(group: 'com.fasterxml.jackson.core', module:'jackson-databind')


    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'

    compile 'com.google.inject:guice:4.0-beta5'
    compile 'com.sun.jersey:jersey-core:1.18.3'
    compile 'com.sun.jersey:jersey-client:1.18.3'

    //testCompile group: 'junit', name: 'junit', version: '4.11'
}


sourceSets {
    main {
        java {
            srcDirs = ['src/main']
        }
    }

    test {
        java {
            srcDirs = ['src/main']
        }
    }
}


test {
    testLogging {
// Show that tests are run in the command-line output
        events 'started', 'passed'
    }
}


task testBaseLineGenerator(type: test) {
    systemProperties['test.single'] = 'BaseLineGenerator'
}

task testTotalLatency(type: test) {
    systemProperties['test.single'] = 'TotalLatencyTest'
}

添加后,我收到 Intellij 错误:

task testBaseLineGenerator(type: test) {
    systemProperties['test.single'] = 'BaseLineGenerator'
}

task testTotalLatency(type: test) {
    systemProperties['test.single'] = 'TotalLatencyTest'
}

我收到此错误:

Error:(56, 0) Cause: org.gradle.api.tasks.testing.Test_Decorated cannot be cast to java.lang.Class
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

尝试了它建议的两个选项,但没有帮助。

最佳答案

我设法解决了我的问题:

我更改为任务 testBaseLineGenerator(type: Test) {

测试而不是测试

关于java - 错误 :(56, 0) 原因 : org. gradle.api.tasks.testing.Test_Decolated 无法转换为 java.lang.Class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28579944/

相关文章:

java - 在 Lucene 内部搜索原始文本而不使用任何分析器

java - date.compare() 不起作用

java - 添加 Java 异常断点在 Eclipse 中不显示任何匹配项

java - IntelliJ IDEA 中的 Vaadin 可视化编辑器无法运行

java - Realm 和 jackOptions Java 以非零退出值 1 完成 - Android Gradle

java - GWT 示例应用程序无法在 IntelliJ IDEA 中运行

java - 使用java创建CSV文件

java - 测试类中的 Spock 框架覆盖方法

Grails 应用程序性能会随着时间的推移而降低

java - groovy代码测试java代码的代码覆盖率