简体   繁体   English

Android Gradle:如何分别运行集成和单元测试?

[英]Android gradle: how to run separately integration and unit tests?

Currently I have standard structure of project: 目前我有标准的项目结构:

src SRC

|---androidTest | --- androidTest

|-------------------|---java | ------------------- | --- java

|----------------------------|---robotium | ---------------- ||-

|----------------------------|---unit | -----------------------------------------------单位

|---main | ---主要

|---------|---AndroidManifest.xml | --------- | --- AndroidManifest.xml

|---------|---java | --------- | --- java

|---------|---res | --------- | --- res

According to documentation 根据文件
I've placed unit and integration tests under androidTest folder. 我已将单元测试和集成测试放置在androidTest文件夹下。

Since instrumentation tests need lot of time, I placed it inside robotium folder(I use Robotium). 由于仪器测试需要大量时间,因此我将其放置在robotium文件夹中(我使用Robotium)。 Inside unti - jUnit tests respectively. 在unti内部-分别进行jUnit测试。

To run all tests I invoke ./gradlew connectedCheck - it's taking lot of time. 要运行所有测试,我调用./gradlew connectedCheck这需要很多时间。

How to to run integration (inside robotium folder) tests and unit tests separately? 如何分别运行集成(在robotium文件夹中)测试和单元测试? I want to run these tests using gradle - it's for CI server. 我想使用gradle运行这些测试-适用于CI服务器。 For example I want to run integration tests every night and unit tests - every hour.. 例如,我想每晚进行集成测试,每小时进行一次单元测试。

Thanks! 谢谢!

According to the documentation JUnit tests should be places under - src/test/java and then you'll be able to switch between test sources by changing Test Artifact when selecting Build variants as shown: 根据文档, JUnit测试应该放在-src / test / java下 ,然后您可以通过在选择Build variants时更改Test Artifact来在test sources之间进行切换,如下所示:

as shown http://tools.android.com/_/rsrc/1423155717194/tech-docs/unit-testing-support/qSxL68MPv5.png?height=365&width=400 如http://tools.android.com/_/rsrc/1423155717194/tech-docs/unit-testing-support/qSxL68MPv5.png?height=365&width=400

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM