gpt4 book ai didi

gradle - 试图使用Gradle运行Spock规范… “Test Events were not received”(在IntelliJ Idea中)

转载 作者:行者123 更新时间:2023-12-03 03:17:29 25 4
gpt4 key购买 nike

我试图在Gradle项目中使用Groovy运行一个简单的Spock规范。但是我收到此消息Test events were not received

这是我的build.gradle:

plugins {
id 'groovy'
}

group 'com.Sample'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'groovy'

repositories {
mavenCentral()
}

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
testCompile "org.spockframework:spock-core:1.1-groovy-2.4"
}

这是我的spock规范:
import spock.lang.Specification
class SampleSpec extends Specification {

def "validate string concat"(){

given:
def string1 = "hello"
def string2 = "world"

when:
def stringConcat = string1.concat(string2)

then:
stringConcat == "helloworld"
}
}

这是我运行Spock规范时收到的消息:
> Task :cleanTest UP-TO-DATE
> Task :compileJava UP-TO-DATE
> Task :compileGroovy NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :compileTestJava NO-SOURCE
> Task :compileTestGroovy NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test NO-SOURCE
BUILD SUCCESSFUL in 0s
2 actionable tasks: 2 up-to-date
9:20:33 AM: Tasks execution finished ':cleanTest :test --tests "SampleSpec.validate string concat"'.

任何帮助将不胜感激!

编辑:
现在我的Spock测试已成功运行,但是我收到此消息:

WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/Users/dtara/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-all/2.4.9/3334e99a8baae12d6e014d444149e337ceb99a00/groovy-all-2.4.9.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

**任何人都知道这意味着什么?我应该担心吗? **

最佳答案

好,第一个问题:

测试应该存在于src/test/groovy中而不是src/test/java中(并且程序包会很好);-)

第二个问题:

您使用的是Groovy的较旧版本,但是直到Groovy 3.0发布,使用Java 9+时,您会看到该警告。它正在尝试使用Java将在将来的版本中删除的功能...

可以使用当前的内容运行(除了可能获取最新的groovy之外-在我写这篇文章时是2.5.8)

关于gradle - 试图使用Gradle运行Spock规范… “Test Events were not received”(在IntelliJ Idea中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57907876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com