如何从测试用例启动/绑定服务。我尝试使用它不起作用的ServiceTestCase
答案 0 :(得分:2)
来自ServiceTestCase
文档:
当您的某个测试方法调用
ServiceTestCase.startService()
或ServiceTestCase.bindService()
时,测试用例会调用Service.onCreate()
,然后根据需要调用Service.startService(Intent)
或Service.bindService(Intent, ServiceConnection, int)
。它还存储跟踪和支持生命周期所需的值。