Running instrumented Android test produces “Unknown command-line option '--tests' ”

Deadly 提交于 2020-03-20 07:46:07

问题


I need to run tests with Gradle in a specific package of my app with a command line, in a fastfile. I'm using this command

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

but it give me this error

Problem configuring task :app:test from command line.

>Unknown command-line option '--tests'.

I tried a lot of variants but no one worked.

Thanks for your help !


回答1:


There is an open issue related to this problem. Please star it and use a specific variant name.

Currently the top-level "test" task doesn't accept the "--tests" argument. Instead, you must run the explicit "test" task for a specific variant (e.g. "testDebugUnitTest").

The syntax you are using is correct as documented in the Gradle User Guide.

But it seems the VariantName can be mandatory as suggested here.

You can find an example in the Android Developers Documentation.

Gradle also allows you to target specific tests using the --tests flag. For example, the following command runs only the sampleTestMethod tests for the specified build variant...

./gradlew testVariantName --tests *.sampleTestMethod



来源:https://stackoverflow.com/questions/42209348/running-instrumented-android-test-produces-unknown-command-line-option-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!