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

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

问题描述

我在 Android Studio 中有这个项目:

I have this project in Android Studio :

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

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

我该怎么做?

推荐答案

首先,您可以使用

./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

如果不想每次运行测试都记住所有的gradle test命令,可以创建一个文件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天全站免登陆