When I want to start specific local unit test (in folder "test") I start (Dev is buildType):
gradlew testDevUnitTest --tests com.example.StringUtilTest.testMethod
OK. It's work.
But also I want to start specific instrumented test method (in folder "androidTest").
gradlew connectedDevAndroidTest --tests com.example.StringUtilTest.testSelectLanguageFragment
But I get error:
> Unknown command-line option '--tests'.
single system property can be used to specify a single test. You can do gradle -Dtest. single=ClassUnderTestTest test if you want to test single class or use regexp like gradle -Dtest. single=ClassName*Test test you can find more examples of filtering classes for tests under this link.
Instrumented tests are tests that run on physical devices and emulators, and they can take advantage of the Android framework APIs and supporting APIs, such as AndroidX Test.
androidTestImplementation—The dependency is only available in the androidTest source set. Android source sets are : main: Contains your app code. This code is shared amongst all different versions of the app you can build (known as build variants) androidTest: Contains tests known as instrumented tests.
You can run all tests in a specific test class like this
gradlew connectedDevAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.example.StringUtilTest
You can run a single test in a specific test class like this
gradlew connectedDevAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.example.StringUtilTest#testSelectLanguageFragment
More info at https://developer.android.com/studio/test/command-line.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With