简体   繁体   English

使用android studio进行单元测试时要运行哪个测试

[英]Which test to run when using android studio for unit testing

I am working through an android app tutorial course on udacity.com. 我正在通过udacity.com上的android应用程序教程课程学习。 I have come to a lesson where it's introducing testing. 我上了一堂介绍测试的课程。 However, the video for the current class is showing how to run a test where only one run test option is available. 但是,当前课程的视频显示了如何在只有一个run test选项可用的情况下run test seen here: https://youtu.be/CHb8JGHU290?t=170 在这里看到: https : //youtu.be/CHb8JGHU290?t=170

but my android studio shows a number of options 但是我的android studio显示了很多选项

http://i.imgur.com/YOjyXyu.png

and I am not sure what is the correct one to use, or even what the differences between them are. 而且我不确定该使用哪种正确的方法,甚至不确定它们之间的区别。 Could anyone shed some light on why I have the 4 different choices and what they are? 谁能阐明我为什么有4种不同的选择以及它们是什么? In particular the first and second options are confusing me. 特别是第一和第二种选择使我感到困惑。 the third and fourth options are intuitive enough to understand. 第三个和第四个选项很直观,足以理解。

Thank you. 谢谢。

The options you are given are: 提供的选项有:

1- Run tests using Gradle: This has been added in version 1.1 of Android Studio, to run tests using Android's build system, Gradle. 1-使用Gradle运行测试:Android Studio版本1.1中已添加此功能,以使用Android的构建系统Gradle运行测试。

2- Run tests using Android JUnit, which will probably require a device/emulator. 2-使用Android JUnit运行测试,这可能需要设备/仿真器。 This is the option to use if you have test cases that make use of Android's test suite, like AndroidTestCase , also useful for running more complex and Android-related test cases. 如果您拥有使用Android测试套件的测试用例(例如AndroidTestCase ,则可以使用此选项,这对于运行更复杂且与Android相关的测试用例也很有用。

3/4 - Run using JUnit framework. 3/4-使用JUnit框架运行。 In your case, the only difference between these options is that the first indicates All Tests available in the project, while the last option offers running all tests existing in the specified package. 就您而言,这两个选项之间的唯一区别是,第一个选项指示项目中所有可用的测试,而最后一个选项提供运行指定包中现有的所有测试。 In your case, probably both options are equivalent. 在您的情况下,可能两个选项都是等效的。

If you are running basic unit tests, I'd definitely stick with the first option. 如果您正在运行基本单元测试,那么我绝对会坚持使用第一个选项。 More details on Android Studio testing here: http://tools.android.com/tech-docs/unit-testing-support 此处提供有关Android Studio测试的更多详细信息: http : //tools.android.com/tech-docs/unit-testing-support

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Android studio中为单元测试配置测试文件夹 - Configure test folder for unit testing in Android studio 在TeamCity中运行android studio项目的单元测试 - Run unit test of android studio project in TeamCity 单元测试方法失败,其中包含lambda表达式Android Studio - Unit Testing method failing which contains lambda expression Android Studio 如何在不使用Android Studio的情况下在Android设备上自动将单元测试作为jar文件或exec文件运行 - How to run unit test as jar file or exec file automatically on android device without using android studio 从Android Studio运行robolectric和android单元测试 - Run robolectric and android unit test from Android studio 如何在Android Studio 1.5中运行单元测试 - How do I run a unit test in Android Studio 1.5 无法在Android Studio中使用调试器运行Robolectric单元测试 - Unable to run Robolectric unit test with debugger in Android Studio Android Studio单元测试配置 - Android Studio Unit Testing Configuration 单元测试 Android Studio Textview - Unit Testing Android Studio Textview 在Android中使用Robotium进行单元测试时,如何从服务器获取运行时数据? - When using Robotium in android for unit testing how to take run time data from server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM