title: How to test a ListActivity?
body: <p>I'm new to Android development as well as test-driven development.  I want to write unit tests for the following ListActivity:</p>
  
  <pre><code>public class TrendsMainActivity extends ListActivity {
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
  
      String[] list_items = getResources().getStringArray(R.array.trend_menu_names);
      setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.main, list_items));
  }
  
  @Override
  protected void onListItemClick(ListView listView, View view, int position, long id)
  {
      Intent intent = null;
  
      switch(position)
      {
          case 0:
              intent = new Intent(this, TrendingActivity.class);
              break;
          case 1:
              intent = new Intent(this, SearchActivity.class);
              break;
          case 2:
              intent = new Intent(this, TimelineActivity.class);
              break;
      }
      if(intent != null)
      {
          startActivity(intent);
      }
      else
      {
          Log.e(getClass().getSimpleName(), "There was an error retrieving request.");
      }
  }}
  </code></pre>
  
  <p>I have scoured all of the documentation that I can find, but I can not figure out how to test this Activity.  The onListItemClick method is not finished, but it gives the idea of what I want to accomplish.  I want to test clicking the first item in the ListView, and test that the correct Activity is being started.  </p>
  
  <p>How can I accomplish this?</p>
  
  <p>Edit: I want my test to "click" on an item in the ListView. I then want to assert that the activity started is the correct activity (e.g. Clicking ListView item 0 starts the TrendingActivity specifically)</p>