Android中的@SmallTest,@MediumTest和@LargeTest注解的目的是什么?

我是Android的新手,我已经看到使用这些注释的示例代码。 例如:

@SmallTest public void testStuff() { TouchUtils.tapView(this, anEditTextView); sendKeys("HELP SPACE ME PERIOD"); assertEquals("help me.", anEditTextView.getText().toString()); } 

这个注释完成了什么?

这篇博客文章解释得最好。 基本上是这样的:

测试图表

  1. 小:此testing不与任何文件系统或networking交互。
  2. 中:访问正在运行testing的盒子上的文件系统。
  3. 大:访问外部文件系统,networking等

根据Android开发者博客 ,一个小testing应该<100ms,一个中等testing<2s,一个大testing<120s。

看到这个页面 (search“@SmallTest”)如何指定哪些testing运行。

除了Davidann的回答 ,主要是OP在评论中的提问 :

在上面的代码的上下文中,除了给其他开发者留下一个注释之外,它实际上是否做了什么? 它执行什么? 有没有使用这个注释的工具? Android开发的目的是什么?

您可以运行一组使用特定注释进行注释的testing。

从AndroidJUnitRunner文档 :

运行特定的testing大小,即用SmallTestMediumTestLargeTest注释:

adb shell我的仪器-w -e大小[小|中|大] com.android.foo/android.support.test.runner.AndroidJUnitRunner

您也可以通过gradle设置这些参数:

android { ... defaultConfig { ... testInstrumentationRunnerArgument 'size', 'Large' } }
android { ... defaultConfig { ... testInstrumentationRunnerArgument 'size', 'Large' } } 

看到这个博客文章的更多细节。