困惑testCompile和androidTestCompile在Android的摇篮 [英] Confused about testCompile and androidTestCompile in android gradle
问题描述
我是新来测试的世界,甚至更多的机器人测试的世界。虽然做研究robolectric与Android上的一件事测试有助于混淆了我最。有时候,在网络上我看到引用robolectric时,而其他人使用androidTestCompile使用testCompile关键字在摇篮构建脚本的依赖关系的人。当然,两者都不能有效吗?
I'm new to testing world and even more to android testing world. While doing research on robolectric that aids with tests on android one thing confuses me the most. Sometimes on the web I see people using testCompile keyword in dependencies of the gradle build script when referencing robolectric while others use androidTestCompile. Certainly both can't be valid?
有人可以解释两者且这些使用robolectric时,应一用吗?
Can somebody explain the difference between the both and which of these should be the one used when using robolectric?
推荐答案
简单地 testCompile
是单元测试配置(那些位于的src /测试)和 androidTestCompile
用于测试API(即位于的src / androidTest 的)。既然你正打算编写单元测试,你应该使用 testCompile
。
Simply testCompile
is the configuration for unit tests (those located in src/test) and androidTestCompile
is used for the test api (that located in src/androidTest). Since you are intending to write unit tests, you should use testCompile
.
更新:这两者之间的主要区别是测试
sourceset运行在一个普通的Java的JVM,而 androidTest
sourceset测试Android设备(或仿真器)上运行。
Update: The main distinction between the two is the test
sourceset runs in a regular Java JVM, whereas the androidTest
sourceset tests run on an Android device (or an emulator).
这篇关于困惑testCompile和androidTestCompile在Android的摇篮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!