Android : Test if Service was started

on Monday, September 22, 2014


I have a class which starts IntentService:



public class MyClass(){
public void doStuff(){
Intent intent = new Intent(context, MyService.class);
intent.putExtra(KEY, stringExtra);
context.startService(intent);
}
}


Now I want to unit-test MyClass. Something like this:



public void testServiceStarted(){
MyClass myClass = new MyClass();
myClass.doStuff();
//Assert MyService was stated and received arguments
}


Is this possible?


0 comments:

Post a Comment