简体   繁体   English

未找到给定包含的测试(IntelliJ 和 Groovy)

[英]No tests found for given includes (IntelliJ & Groovy)

I am attempting to run unit tests written in Groovy, using IntelliJ and./gradlew command.我正在尝试使用 IntelliJ 和 ./gradlew 命令运行用 Groovy 编写的单元测试。 Building the project works fine, however the tests do not seem to be found.构建项目工作正常,但似乎没有找到测试。 Running the tests in IntelliJ throws the following code:在 IntelliJ 中运行测试会引发以下代码:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> No tests found for given includes: [path.to.SomeTestClass](filter.includeTestsMatching)

No tests in my project are found, below is an example class I created in the project under src -> main -> test -> groovy directory.在我的项目中没有找到测试,下面是我在src -> main -> test -> groovy目录下的项目中创建的示例 class。

import spock.lang.Specification

class SomeTestClass extends Specification {

    def "A test that should work"() {

        given:
        def someNumber = 1

        when:
        def anotherNumber = someNumber + 1

        then:
        anotherNumber == 2
    }
}

Would appreciate any help!将不胜感激任何帮助!

Solution:解决方案:

This was solved by adding the following lines to build.gradle:这通过在 build.gradle 中添加以下行来解决:

test {
    useJUnitPlatform()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 IntelliJ IDEA 中运行 Gradle 测试时出现“未找到给定包含的测试” - "No tests found for given includes" when running Gradle tests in IntelliJ IDEA 未找到给定的测试包括:JUNIT - No tests found for given includes: JUNIT 没有找到给定的测试包括 Junit 5 - No tests found for given includes Junit 5 “对于给定的测试没有找到包括”TestNG + Gradle + @Test(dependsOnMethods) - “No tests found for given includes” for TestNG + Gradle + @Test(dependsOnMethods) 未找到给定包括的测试:[***Test](filter.includeTestsMatching) - No tests found for given includes: [***Test](filter.includeTestsMatching) 自定义文件夹中的集成测试:任务“:integrationTest”执行失败。 没有找到给定的测试包括 - Integration test in custom folder: Execution failed for task ':integrationTest'. No tests found for given includes Intellij 无法正确识别 Groovy 测试 - Intellij doesn't recognize Groovy tests properly 找不到与IntelliJ中的Method main匹配的测试 - No tests found matching Method main in IntelliJ IntelliJ 没有找到退出代码为 0 的测试 - IntelliJ No tests were found with exit code 0 仅当按下重新运行失败的测试时,才使用 gradle 和 intellij 未找到测试 - Not test found with gradle and intellij only when press rerun failed tests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM