在Android Studio中运行所有单元测试 [英] Run all unit tests in Android Studio

查看:286
本文介绍了在Android Studio中运行所有单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android Studio中有这个项目:

I have this project in Android Studio :

我希望一键式运行所有项目中的所有单元测试.

I wish to run all unit tests in all project with one click.

我该怎么做?

推荐答案

首先,您可以列出项目中可用的所有测试任务,

First, you can list all the test tasks available in your project with

./gradlew tasks

然后,您可以选择要执行的任务.如果要对所有口味和所有buildTypes执行所有测试,则只需运行

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

如果您不想每次运行测试时都记住所有gradle测试命令,则可以创建文件"custom_tasks.gradle"并添加

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"
}

然后,您只需要运行

./gradlew testAll

这篇关于在Android Studio中运行所有单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆