了解android测试需要查询android官方文档,android官方培训教程Getting Started with Testing介绍了android提供的测试类型,测试接口等,相较与网上总结的android自动化测试框架,官方文档显然分类更合理,定位更准确.
https://developer.android.com/training/testing/
两种测试类型
在使用Android Studio创建模块时会在src
下生成androidTest
和test
两个用于测试的的目录,对应下面两种测试类型.
![[Android自动化测试一 UiAutomator官方介绍.png]]
本地单元测试(Local unit tests)
位于module-name/src/test/java/.
下,运行在PC端本地的JVM虚拟机上,并且不能访问Android框架的接口.
参考Building Local Tests
设备化测试
位于 module-name/src/androidTest/java/.
下,必须运行在Android物理设备和虚拟机上.
参考Building Instrumented Unit Tests
Instrumented unit tests are tests that run on physical devices and emulators, and they can take advantage of the Android framework APIs and supporting APIs, such as the Android Testing Support Library. You should create instrumented unit tests if your tests need access to instrumentation information (such as the target app's Context) or if they require the real implementation of an Android framework component (such as a Parcelable or SharedPreferences object).
Using instrumented unit tests also helps to reduce the effort required to write and maintain mock code. You are still free to use a mocking framework, if you choose, to simulate any dependency relationships.
设备化单元测试分为:
- 设备化单元测试(Instrumented Unit Test):Building Instrumented Unit Tests: Build complex unit tests with Android dependencies that cannot be satisfied with mock objects.
- 组件集成测试:Automating User Interface Tests: Create tests to verify that the user interface behaves correctly for user interactions within a single app or for interactions across multiple apps.
- app集成测试:Testing App Component Integrations: Verify the behavior of components that users do not directly interact with, such as a Service or aContent Provider.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。