【问题标题】:Running instrumented Android test produces "Unknown command-line option '--tests' "运行检测的 Android 测试会产生“未知的命令行选项'--tests'”
【发布时间】:2017-02-13 16:53:04
【问题描述】:

我需要使用 Gradle 在我的应用程序的特定包中使用命令行在 fastfile 中运行测试。 我正在使用这个命令

sh './gradlew test --tests "com.package.exemple.*"'

但它给了我这个错误

从命令行配置任务 :app:test 时出现问题。

>未知的命令行选项'--tests'。

我尝试了很多变体,但没有一个奏效。

感谢您的帮助!

【问题讨论】:

    标签: android testing gradle fastlane


    【解决方案1】:

    有一个open issue 与此问题相关。请给它加星标并使用特定的变体名称。

    目前顶级“test”任务不接受“--tests” 争论。相反,您必须为特定的运行显式“测试”任务 变体(例如“testDebugUnitTest”)。

    您使用的语法是正确的,如 in the Gradle User Guide 所述。

    但似乎VariantName 可以像建议的here 那样是强制性的。

    你可以找到一个例子in the Android Developers Documentation

    Gradle 还允许您使用 --tests 来定位特定测试 旗帜。例如,以下命令仅运行 sampleTestMethod 测试指定的构建变体...

    ./gradlew testVariantName --tests *.sampleTestMethod

    【讨论】:

    • 它显然不会得到修复,有什么解决方法吗?
    猜你喜欢
    • 2016-11-11
    • 2012-06-24
    • 1970-01-01
    • 2013-06-11
    • 2011-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多