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


Other Threads

1. Update Gallery and Listview after Thread

Hi,

I have a Gallery with ImageAdapter and a Listview with
EfficientAdapter
.. both come initialized with a set of Data in an Array.

Now i update the Data by downloading new Infos from the Net in a
Thread.
I know from debugging that the Arrays are updated, but not the GUI.

So how to update the GUI?

I know its not possible to update the GUI while I am in the Thread, so
I have a
second Thread where I update my other Informations, like my Textview.
There it works perfectly, but still my Gallery and Listview dont
update.

I would really appreciaty you share you Experience with me.
For sure If you need my source, let me know.

Please if possible with "short" Examples

Thanks
Chris
--~--~---------~--~----~------------~-------~--~----~

2. PDU Column Names

I'm looking for the To field, From Field or Name field in the txt/sms
message tables.  I know the content uri: content://mms/inbox and
thread_id seems to be a column, but I can't find anything else.

Thanks,

Justin

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

3. Sending and receiving data messages via a BroadcastReceiver

4. how to build library without optimization in order to properly debug it

5. How to add activity to application to the task history(long press home key)

6. Would you like to let me know how to get SDK version in my application code?

7. OpenGL CompressedTexture2D texture compression problem.