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

编程入门 行业动态 更新时间:2024-10-14 12:24:14
本文介绍了在 Android Studio 中运行所有单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我在 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屋!

更多推荐

[db:关键词]

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

发布评论

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

>www.elefans.com

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