简体   繁体   中英

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

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 !

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 (eg "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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM