Gradle Wrapper 4.6无法识别测试过滤参数

时间:2018-06-26 10:11:52

标签: android testing gradle junit

我无法使用gradle wrapper过滤测试,因为无法识别--tests参数:

bash

如您所见,帮助输出中没有这样的参数。

❯ ./gradlew test --continuous --tests "pt.joaomneto.titancompanion.adventure.twofm.TWOFMAdventureStateTest"                                                                                                                                                                                                              

Continuous build is an incubating feature.

> Configure project :
TitanCompanion: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.android.databinding:compiler:3.2.0-alpha10' and apply the kapt plugin: "apply plugin: 'kotlin-kapt'".


FAILURE: Build failed with an exception.

* What went wrong:
Problem configuring task :test from command line.
> Unknown command-line option '--tests'.

* Try:
Run gradlew help --task :test to get task usage details. 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 1s

我正在使用gradle 4.6

❯ ./gradlew help --task :test                                                                                                                                                                                                                                                                                          

> Configure project :
TitanCompanion: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.android.databinding:compiler:3.2.0-alpha10' and apply the kapt plugin: "apply plugin: 'kotlin-kapt'".

> Task :help
Detailed task information for :test

Path
     :test

Type
     Task (org.gradle.api.Task)

Description
     Run unit tests for all variants.

Group
     verification

我在这里做错了什么?该文档明确指出,我可以使用此参数来过滤测试:https://docs.gradle.org/4.6/userguide/java_plugin.html#test_filtering

您能在这里帮助我吗?

编辑:这仅在Android项目中发生。在标准kotlin + spring项目中使用相同的gradle版本,即可正常运行...

1 个答案:

答案 0 :(得分:0)

在所有这些时间之后回答我的问题:

问题出在以下事实:Android插件将测试任务用作更具体任务的保护伞,并且无法识别--tests过滤器参数。因此解决此问题的方法是指定所需的测试任务,在我的情况下,必须是:

./gradlew testDebugUnitTest --tests pt.joaomneto.titancompanion.adventure.twofm.TWOFMAdventureStateTest

如此处所述:https://developer.android.com/studio/test/command-line