src/androidtest 和 src/test 文件夹有什么区别? [英] What's the difference between src/androidtest and src/test folders?

查看:39
本文介绍了src/androidtest 和 src/test 文件夹有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个项目中,在Android Studio中,默认有两个test文件夹.

In a project, in Android Studio, by default, there are two test folders.

第一个是src/androidTest.这个文件夹已经存在于之前版本的 Android Studio 中.尽管如此,现在有一个新的测试文件夹,默认情况下,src/test,以及新的依赖,testCompile 'junit: junit: 4.12' in build.gradle.

The first is src/androidTest. This folder already existed in the previous version of Android Studio. Nevertheless, there is now a new test folder, by default, src/test, and new dependence, testCompile 'junit: junit: 4.12' in build.gradle.

我使用哪个文件夹进行测试?两者有什么区别?

Which folder do I use for testing? What are the differences between the two?

推荐答案

src/androidTest 用于涉及 android 检测的单元测试.

src/androidTest is for unit tests that involves android instrumentation.

src/test 用于不涉及安卓框架的纯单元测试.您可以在此处运行测试,无需在真实设备或模拟器上运行.

src/test is for pure unit test that do not involve android framework. You can run tests here without running on a real device or on emulator.

您可以使用这两个文件夹.使用第一个来测试使用 Android 框架的代码.使用第二个来测试纯 java 类的代码.编写测试的方法几乎相同.

You can use both folders. Use the first one to test code that use Android framework. Use the second one to test code that are pure java classes. The methods to write tests are almost the same.

更多信息:http://developer.android.com/tools/testing/testing_android.html

这篇关于src/androidtest 和 src/test 文件夹有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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