Run all unit tests in Android Studio

后端 未结 5 1537
渐次进展
渐次进展 2020-12-15 02:20

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 ?

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 03:03

    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
    

提交回复
热议问题