I have this project in Android Studio :
I wish to run all unit tests in all project with one click.
How i can do it ?
By default, Unit tests are written in src/test/java/ folder and Instrumentation tests are written in src/androidTest/java/ folder. Android studio provides Run context menu for the test classes to run the test written in the selected test classes.
Not sure what version of Android Studio this was added in, but I'm using Android Studio 3.4.
In the Project Explorer Window, select the Project View.
Right click on your root project and select "Create 'All Tests'..."
...this window will appear (these defaults need to be changed)
Change the following options:
Search for tests:
JRE:
Click Apply
First, you can list all the test tasks available in your project with
./gradlew tasks
Then you can choose the tasks you want to execute. If you want to execute all tests for all flavors ans all buildTypes, you just have to run
./gradlew test connectedAndroidTest
If you don't want to remember all the gradle test command each time you want to run the tests, you can create a file "custom_tasks.gradle" and add
task testAll(dependsOn: ['test', 'connectedAndroidTest']) { group = 'custom_tasks' description = "Run all tests" }
Then, you just have to run
./gradlew testAll
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