March 2015
Beginner to intermediate
274 pages
6h 1m
English
When you want to test an android.app.Service, the idea is to extend the ServiceTestCase<Service> class to test in a controlled environment:
public class DummyServiceTest extends ServiceTestCase<DummyService> {
public DummyServiceTest() {
super(DummyService.class);
}
public void testBasicStartup() {
Intent startIntent = new Intent();
startIntent.setClass(getContext(), DummyService.class);
startService(startIntent);
}
public void testBindable() {
Intent startIntent = new Intent();
startIntent.setClass(getContext(), DummyService.class);
bindService(startIntent);
}
}The constructor, as in other similar cases, invokes the parent constructor that passes the Android service class as a parameter.
This is followed by testBasicStartup() ...
Read now
Unlock full access