0

I am still figuring out Android unit tests. Also, still somewhat new to android and so some of the UI components puzzle me a little. I have inherited a complex android application with no unit tests and am attempting to write unit tests as I work on things.

I have an activity that extends ActionBarActivity and is basically a menu. The activity contains one listview and each item has an icon. Clicking an item in the list view takes you to another activity.

The items on the listview are conditionally added. I have been able to access the listview, and make sure the proper items are added in the proper condtions.

Now I want to go through the list view one at a time and click the item and make sure the right activity is getting launched.

I've read the documentation here: http://developer.android.com/training/activity-testing/activity-ui-testing.html, but it seems to me that dynamic list views are a little different since the list view has a name, but it's individual items all have the same name, right?

So how do I access the individual rows of my listview and click them to check my event?

Thom
  • 14,013
  • 25
  • 105
  • 185

2 Answers2

0

If you are using the custom listview Then it could be done in the ListAdapter. I think the Right place is in the GetView function and also get Id. You can track them , as when they get Id or when they get view.

stacy queen
  • 280
  • 1
  • 4
  • 19
  • Thanks for the interest. I'm using ListView listView = (ListView) activity.findViewById(android.R.id.list); SimpleAdapter listAdapter = (SimpleAdapter) listView.getAdapter(); View view = listAdapter.getView(0, convertView, listAdapter); What do I use for convertView and parent on getView()? I think listAdapter is the parent. – Thom May 13 '15 at 14:12
  • I was talking about the custom listview – stacy queen May 13 '15 at 14:19
0

If you are trying to programatically click an individual item from a list view as part of an automated test, I think this post will be helpful. Android - ListView - performItemClick

Community
  • 1
  • 1
wolfaviators
  • 503
  • 1
  • 7
  • 21