Intelij 2019.1 update breaks JUnit tests

前端 未结 6 1992
长情又很酷
长情又很酷 2020-12-29 06:14

After 2019.1 update broke all tests with error:

no tests found for given includes xxxx.someThingTest

相关标签:
6条回答
  • 2020-12-29 06:38

    I experienced the same problem in 2019.2 for a newly developped class that was not detected. I strangely solved it by manually running "Build->Rebuild Project"

    The workaround with Runner by Mike was not working for me.

    0 讨论(0)
  • 2020-12-29 06:38

    Switching to JDK 11.0.2 solved this for me. Not sure if it is the real cause, though.

    0 讨论(0)
  • 2020-12-29 06:40

    If you are using JUnit5 with Gradle, add below code to build.gradle file.

    test {
        useJUnitPlatform()
    }
    

    I've got a hint from https://www.baeldung.com/junit-5-gradle

    0 讨论(0)
  • 2020-12-29 06:43

    When using JUnit 5, make sure that you use the interfaces provided by org.junit.jupiter

    So for instance, you should annotate your tests with org.junit.jupiter.api.Test instead of org.junit.Test

    For JUnit 4, and prior, use the interfaces provided by org.junit

    0 讨论(0)
  • 2020-12-29 06:55

    Intelij somehow changed setting with update.

    Settings > Build,Execution,Deployment > Build Tools > Gradle > Runner > "Run tests using:"

    Changed from "Gradle Test runner" to "Platform Test runner" and it worked. I hope this is useful in some matter.

    0 讨论(0)
  • 2020-12-29 06:58

    Checkout this build.gradle file for using Junit5

    https://github.com/junit-team/junit5-samples/blob/r5.4.0/junit5-jupiter-starter-gradle/build.gradle

    0 讨论(0)
提交回复
热议问题