7

いろいろ検索しましたが、残念ながらうまくいきませんでした。

私の検索に基づいて、次のコードを build.gradle ファイルに追加する必要があることがわかりました。ただし、Gradleはそれを認識していないようで、常にGeadle DSL method not found: test()

test  {
    testLogging.showStandardStreams = true
    testLogging.events("passed", "skipped", "failed", "standardOut", "standardError")

    afterTest { desc, result ->
        println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
    }
}

アップデート

src/test/javaテストプロジェクトを作成し、すべてのテストケースをsrc/androidTest/javaメインプロジェクトではなくその中に移動すると、上記のコードまたは次のコードが正常に機能することを確認できます。javabuild.gradle ファイルでプラグインを適用できるためです。com.android.*ただし、定義されているbuild.gradle ファイルで次のコードを使用することはできません。これら2つのライブラリは互換性がないため:(

apply plugin: 'java'
evaluationDependsOn(':YOUR-LIB')

test {
    testLogging.showStandardStreams = true

    testLogging {
        events "passed", "skipped", "failed", "standardOut", "standardError"
        exceptionFormat = 'full'
    }

    afterTest { desc, result ->
        println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
    }

    forkEvery = 5
    maxParallelForks = java.lang.Runtime.runtime.availableProcessors() / 2
}

tasks.withType(Test) {
    // Need Gradle to ignore classes that are inner class of Test classes but not actually Tests
    scanForTestClasses = false
    include "**/*Test.class"
}

だから、私の質問は、誰かがandroidプラグインの下でログを印刷する方法を考案したことですか?

4

0 に答える 0