Testing Views - iOS

"Luther Baker [email protected] [testdrivendevelopment]" <[email protected]> Fri, 30 May 2014 09:22:30 -0500
Newsgroups gmane.comp.programming.test-driven-development
Message-ID <CAL5Mv1=-RbH8YKApHLYexyBw1nX21TeQC2QdKtZL+rMAxPSEBA@mail.gmail.com>
I've essentially broken my GUI logic out into a rough MVP pattern and while
I find testing the Models and Presenters straightforward, I haven't come up
with a repeatable process to test drive the code in the Views.


Granted, my views are dumb and have no real business logic - but for
instance, if something is disabled, I could test that certain fields are
set to 'readonly', or greyed out, etc.


I generally use mocks and inject dependencies everywhere else in the app -
but that isn't as feasible in the views. Buttons, toggles and segemented
controls aren't something the parent view can just swap out, replace and
layout correctly. Injection doesn't feel right and so, because Views are so
'self contained' - I find myself newing child components up inside of their
parent views and as such, I'm not sure how to TDD them without exposing
their internals somehow.


Would great appreciate some suggestions.


Thanks,
-Luther