Reputation: 17695
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 ?
Upvotes: 117
Views: 66712
Reputation: 11
Open Android Studio Giraffe | 2022.3.1
Upvotes: 1
Reputation: 1833
If you're having issues running the command from cmd. You can run the command in android studio
Click on Gradle on the right side of Android Studio.
Click on "Execute Gradle Task" icon
Type command "gradle test connectedAndroidTest" and enter
Upvotes: 0
Reputation: 4305
With AndroidStudio ArcticFox the approach is as follows:
In the toolbar under the run configuration select "Edit Configurations"
Select (+) to add a new configuration and choose Gradle:
On the configuration page:
cleanTestDebugUnitTest testDebugUnitTest
(you can copy that from an existing configuration for unit tests, but make sure to remove the module prefix (e.g. :app:))--tests "*"
as Arguments (apparently that tells AS to show the results as TestResults)Select and run your new configuration. The Results will be shown in the run window:
Upvotes: 41
Reputation: 3421
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
Upvotes: 82
Reputation: 4897
Upvotes: 22
Reputation: 760
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
Upvotes: 63
Reputation: 732
You can try to use this command line on the android terminal: Mac:
./gradlew test connectedAndroidTest
Windows:
gradlew test connectedAndroidTest
Upvotes: 12