我有以下设计:
public class MyService extends Service{
protected Logger _log;
int _counter;
onStartCommand(...){
_log.print (++_counter);
}
}
public class MyServiceTestWrapper extends MyService{
public void setLog(Logger mockLogger){ _logger = mockLogger; }
}
public class MyServiceTest extends ServiceTestClass<MyServiceTestWrapper>{
public void test_myTest(){
Logger fakeLogger = Mockito.Mock(Logger.class);
// HERE IM NOT SURE HOW TO CONTINUE...
//...
//...
Mockito.verify(fakeLogger.write(Mockito.any(String.class))).times(3);
}
}
如何获取服务实例并对 onStartCommand 进行 3 次调用?
谢谢您的帮助