Gradle DSL method not found: test()

后端 未结 1 1182
长情又很酷
长情又很酷 2020-12-10 08:25

Tried to add the following code at the end of my build.gradle file in Android-Studio 1.2 (as advised in this post):

test {
    testLogging {
            


        
相关标签:
1条回答
  • 2020-12-10 08:49

    The gradle documentation: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html

    indicates that the 'test' task is sourced from the java plugin:

    apply plugin: 'java' // adds 'test' task
    

    This as you say conflicts with the com.android.application plugin.

    Solution

    I have finally worked out how to do this. Rather than apply the logging changes to the test tasks (which is only available from java plugin) you can apply it to all tasks of type 'Test' as follows:

    //Test Logging
    tasks.withType(Test) {
        testLogging {
            events "started", "passed", "skipped", "failed"
        }
    }
    

    Now when you run ./gradlew test you should get these events logged as the tests are processed.

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