I am being faced with this issue, basically the ServiceTestRule throws a TimeoutException when startService is called in an unbound services, and would like to know if someone knows of a possible workaround until a fix is released?
The unbound service class:
public class UnboundService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
The test class:
@RunWith(AndroidJUnit4.class)
@MediumTest
public class UnboundServiceTest {
@Rule
public final ServiceTestRule serviceRule = new ServiceTestRule();
@Test
public void worksAsStartedService() throws TimeoutException {
Intent intent = new Intent(InstrumentationRegistry.getTargetContext(), UnboundService.class);
serviceRule.startService(intent);
}
}