Issue
I'm trying to test my UI within an Activity. However, this Activity performs some background network operations and on the response updates it's fragments to the actual component that I'm trying to test.
My unit test is failing because it is trying to assertNotNull on the views that have been rendered to the screen yet.
How would I go about signaling to my unit test that the Activity has performed this background operation and everything should be ready for setUp and testing?
Solution
After doing some research and some more playing around it seems that there are two ways to do this. First you can as @yorkw suggests, use sleep() and try to time everything.
My gut is telling me that this isn't the best idea. There is just a bunch of problems that you can run into with this. A better solution would be to take testing into account as your writing your application. I've watch a few videos about unit testing and this one Google talk stood out. Clean Code Talks After watching this and then trying write tests for hard to test code, I have a whole new appreciation for writing unit test and separating my business logic from the implementation/display logic.
So the simple answer is implement your application better to avoid having these issues.
Answered By - Frank Sposaro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.