测试类型
Local unit tests
Local unit tests的代码应该写在:module-name/src/test/java/。Local unit tests运行在本机的JVM(Java Virtual Machine)中,所以运行速度很快。但是不能测试Android framework的功能,因为在unit tests中,android framework是一个处理过的framework,所有的方法只剩下方法签名,内部实现都是空。
但是如果集成Mockito来mock Android framework,也可以在unit tests中测试Android framework的功能。
Instrumented tests
Instrumented tests的代码应该写在:module-name/src/androidTest/java/。Instrumented tests运行在手机上,可以通过Instrumentation API,在test的代码中控制APP。