Hi,

I've recently started implementing tests for some of my activities and
seeing how far I could take the unit tests vs the integration tests. I
was pleasantly surprised to find that I could actually do A LOT more
than what would seem apparent, at least from what could be gleaned
from documentation and posts.  However, I ran into some surprising
limitations while testing Spinners, particularly the
OnItemSelectedListener.

I say surprising because in the same activity I have an EditText that
has a TextChangedListener (a TextWatcher). This can be tested
successfully, meaning that I can set the text executes the code in the
afterTextChanged with no problems. When testing the Spinner, I have
found that calling setSelection() has no effect, calling
getSelectedItem() immediately afterwards returns null, and the
OnItemSelectedListener is never executed. This is when calling it from
both the Activity itself or from the test.

I also tried all of the different combinations of threads
(runOnMainSync, runOnUiThread, etc), to no avail. Is this simply a
limitation of Unit tests? Why does the text listener work?

Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to