在Android Studio中运行所有单元测试

编程入门 行业动态 更新时间:2024-10-27 06:32:32
本文介绍了在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中运行所有单元测试

本文发布于:2023-11-24 05:05:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624068.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元测试   Android   Studio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!