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
. I want to check if the intent to start my service was fired and that it has correct extras. Something like this:
public void testServiceStarted(){
MyClass myClass = new MyClass();
myClass.doStuff();
// Assert MyService was stated and received arguments
}
Is this possible with Instrumentation or other frameworks?