在android中的TestCase中启动服务

时间:2011-11-23 07:36:35

标签: android testing service servicetestcase

如何从测试用例启动/绑定服务。我尝试使用它不起作用的ServiceTestCase

1 个答案:

答案 0 :(得分:2)

来自ServiceTestCase文档:

  

当您的某个测试方法调用ServiceTestCase.startService()ServiceTestCase.bindService()时,测试用例会调用Service.onCreate(),然后根据需要调用Service.startService(Intent)Service.bindService(Intent, ServiceConnection, int)。它还存储跟踪和支持生命周期所需的值。