I have a working Service (I know it works, because I manually tested). However, I am trying to build JUnit/Espresso test case for it. Though Android Studio told me that the test "passed, " but I don't see the effect from invoking the service. I tried to put some debugging message ,"Starting the service", but **I don't see any of the log message on the console.
Does anyone have any idea? Thanks!
private static StringBuilder log = new StringBuilder();
@Test
public void testWithoutLocation(){
Intent intent = new Intent(InstrumentationRegistry.getContext(), SendMessage.class);
intent.putExtra(BaseService.TAG_PERSON_ID, "ABCD");
intent.putExtra(BaseService.TAG_MESSAGE_ID, "12345");
try {
log.append("Starting the service");
oServiceTestRule.startService(intent);
} catch (TimeoutException e) {
e.printStackTrace();
fail("TimeoutException caught");
}
}
With your current
snip, I saw only one issue that you forget to show thelog. So, make sure your test is run (passed as you said) and yourlogcatis activated (and selectverboselevel). So, try to change this:If it's still not working, try to restart
logcator add more information.