getApplicationContext returns null in test case (unless you sleep first)

by AndyM » Thu, 05 Mar 2009 02:20:38 GMT


Sponsored Links
 I have a simple androidTestCase class that has this test:

@MediumTest
public void testFoo() {
          assertNotNull(this.mContext.getApplicationContext());
}

this fails unless I sleep first, then it passes. Whats the deal?


--~--~---------~--~----~------------~-------~--~----~



getApplicationContext returns null in test case (unless you sleep first)

by AndyM » Thu, 05 Mar 2009 23:04:57 GMT


 "There are APIs to allow you to run code on the main thread to access
its objects." I'm a little confused about what APIs you are talking
about and how they would help solve this problem. Could you clarify?

To me it seems that the test runner should not be calling my tests if
the Application is not finished initializing yet.

Andy





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links