I've been starting to read up on android testing: http://ift.tt/1WJyJOI
I'm confused what should be tested in an app. Obviously simple, non-android specific methods like one that would sort a list of full names by last name should be unit tested.
But what if I had a method that iterated through a layout to determine the child view that was selected, is that suitable for unit testing with a sample input layout, or does this fall under functional/ui testing? The method looks like this:
public void setSelectedPerson(ViewGroup vg, View selected) {
for(int i=0; i < vg.getChildCount(); i++) {
View v = vg.getChildAt(i);
if(v == selected) {
selectedPerson = (Person)v.getTag();
}
}
}
I could test this through a UI test that clicked on part of the app and verified the result. But is that overkill? Would a more appropriate test be a unit test to create a very basic viewgroup with 2 children, assign one of them to "selected", and finally make sure the selected Persons object match?
Aucun commentaire:
Enregistrer un commentaire