且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

没有找到摇篮DSL方法:测试()

更新时间:2023-08-21 20:23:58

该文件的gradle:https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html

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

表示测试任务从Java插件来源:

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

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

这就像你说的com.android.application插件冲突。

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

解决方案

我终于摸索出如何做到这一点。而不应用日志更改测试任务(这是唯一可用的Java插件),可以按如下把它应用到类型测试的所有任务:

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"
    }
}

现在,当您运行 ./ gradlew测试你应该得到这些事件记录为测试进行处理。

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