AbstractMapSelectionActivity extends ListActivity { @Override protected void onListItemClick(final ListView listView, final View view, final int position, final long id) { final String mapName = ((TextView) view).getText().toString(); startActivity(getIntentWithMapName(mapName)); }  abstract Intent getIntentWithMapName(final String mapName);  }
@Test public void testOnListItemClickStartsNicActivity() { final AbstractMapSelectionActivity activitySpy = spy(activity); doNothing().when(activitySpy).startActivity(any(Intent.class)); final ListView listView = mock(ListView.class); final TextView view = mock(TextView.class); when(view.getText()).thenReturn("test"); activitySpy.onListItemClick(listView, view, 0, 0L); verify(activitySpy, times(1)).startActivity(any(Intent.class)); }