Gradle JunitテストエラーNo tests found for given includes:[XXX](filter.includeTestsMatching)

3065 ワード

Testing started at 15:27 ...
> Task :cleanTest
> Task :compileKotlin NO-SOURCE
> Task :compileJava NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :compileTestKotlin
> Task :compileTestJava NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> No tests found for given includes: [App.checkDirExist](filter.includeTestsMatching)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
3 actionable tasks: 3 executed

解決の方向は二つに分かれている


Gradle問題


チェックbuild.gradleには、次の文が含まれています.
test {
    useJUnitPlatform()
}

JUnitコードの問題


テストコードが不正であるかどうかを確認します.
@Test
fun checkDirExist(): Boolean {
   File(BASE_PATH.plus("/newFolder")).run {
     return exists() && isDirectory
   }
}

上の書き方は間違いを報告するに違いないJUnit