【发布时间】:2016-12-07 01:47:34
【问题描述】:
如何在不使用已弃用的 ServiceTestCase 的情况下在 android 中测试 IntentService?
来自ServiceTestCase的文档:
此类在 API 级别 24 中已弃用。 请改用 ServiceTestRule。应使用 Android 测试支持库编写新测试。
但是ServiceTestRule 文档说它不支持IntentServices:
注意:此规则不支持 IntentService,因为它会在 onHandleIntent(android.content.Intent) 完成所有未完成的命令时自动销毁。 所以不能保证及时建立成功的连接。
那么我应该如何测试IntentService?
【问题讨论】:
标签: android unit-testing android-testing android-espresso intentservice