问题
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