What is the purpose of @SmallTest, @MediumTest, and @LargeTest annotations in Android?
This blog post explains it best. Basically, it is the following:
- Small: this test doesn't interact with any file system or network.
- Medium: Accesses file systems on box which is running tests.
- Large: Accesses external file systems, networks, etc.
Per the Android Developers blog, a small test should take < 100ms, a medium test < 2s, and a large test < 120s.
See this page (search for "@SmallTest") on how to specify which tests get run.
As an addition to Davidann's answer and mainly OP's question in the comment:
In the context of the code above, does it actually DO anything except leave a note for other developers? Does it enforce anything? Are there any tools that utilizes this annotation? What's it's purpose in Android development?
You can run a group of tests annotated with specific annotation.
From AndroidJUnitRunner documentation:
Running a specific test size i.e. annotated with SmallTest or MediumTest or LargeTest:
adb shell am instrument -w -e size [small|medium|large] com.android.foo/android.support.test.runner.AndroidJUnitRunner
You may also setup those params through gradle:
android {
...
defaultConfig {
...
testInstrumentationRunnerArgument 'size', 'Large'
}
}
Via gradle:
-Pandroid.testInstrumentationRunnerArguments.size=small
See Doug Stevenson blog post as well as this blog post for more details.