### Question:
ChooseGroupActivity extends ListActivity { @Override protected void onListItemClick(ListView l, View v, int position, long id) { Group g = (Group) getListView().getAdapter().getItem(position); if (!g.isSectionHeader()) { DataSource.getInstance().storeGroup(g); Intent data = new Intent(); data.putExtra("insert_id", g.getId()); setResult(RESULT_OK, data); finish(); } }    }### Answer:
@Test public void test_onListItemClick() { Group g = new Group("groupName"); g.setSectionHeader(false); g.setId(0); GroupListAdapter groupListAdapter = new GroupListAdapter(mActivity, new Group[] { g }); mActivity.getListView().setAdapter(groupListAdapter); mActivity.onListItemClick(mActivity.getListView(), null, 0, 0l); assertTrue(mActivity.isFinishing()); }
@Test public void test_onListItemClick_header() { Group g = new Group("groupName"); g.setSectionHeader(true); g.setId(0); GroupListAdapter groupListAdapter = new GroupListAdapter(mActivity, new Group[] { g }); mActivity.getListView().setAdapter(groupListAdapter); mActivity.onListItemClick(mActivity.getListView(), null, 0, 0l); assertFalse(mActivity.isFinishing()); }