测试类型
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。
本文介绍了Android开发中的两种主要测试类型:Localunittests和Instrumentedtests。Localunittests用于快速测试代码逻辑,而Instrumentedtests则运行在真实设备上,通过InstrumentationAPI控制APP进行功能验证。文中还提到了如何使用Mockito来辅助测试。
608

被折叠的 条评论
为什么被折叠?



