简体   繁体   English

为什么要在 Android 中拆分单元测试和检测测试文件夹?

[英]Why split unit tests and instrumented tests folders in Android?

Out of curiosity, I am wondering why Android splits instrumented and unit tests folders.出于好奇,我想知道为什么 Android 会拆分检测和单元测试文件夹。

I am well aware of the thus offered ability to have different dependencies for each.我很清楚这样提供的能力,可以为每个人提供不同的依赖关系。 Are there any other reasons to do so?还有其他理由这样做吗?

Well for one, unit test can run on its own (no emulator / device needed), so you can easily run a package full of unit tests vs a package mixed although it is possible to combine them.一方面,单元测试可以独立运行(不需要仿真器/设备),因此您可以轻松运行充满单元测试的 package 和混合的 package,尽管可以将它们组合起来。 A typical unit test runs around less than a second while a typical instrument test could run as long as hours etc.典型的单元测试运行时间不到一秒,而典型的仪器测试可能运行长达数小时等。

Why splits instrumented and unit tests folders?为什么要拆分检测和单元测试文件夹?

  • unittests run fast (ie 100 tests per second) on the pc without the need to deploy them on device/emulator and can therefore be executed often (ie 100 times a day ie after small changes or before checkin-to-sourcecode-repository)单元测试在 pc 上运行速度很快(即每秒 100 次测试),无需将它们部署在设备/模拟器上,因此可以经常执行(即每天 100 次,即在小的更改之后或签入到源代码存储库之前)
  • instrumentation test are slow (ie 1 test needs 0,5 to 10 seconds) plus deployment on device/emulator is needed (extra 30 seconds).仪器测试很慢(即 1 次测试需要 0.5 到 10 秒)加上需要在设备/模拟器上部署(额外 30 秒)。 These tests are usually run not that often (ie at night or at the lunch break)这些测试通常不经常运行(即在晚上或午休时间)

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

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