Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 !

like image 333
Medsic Avatar asked Oct 18 '22 17:10

Medsic


1 Answers

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

like image 153
albodelu Avatar answered Oct 21 '22 04:10

albodelu