Unit Tests

by Keean Schupke » Thu, 17 Dec 2009 21:13:15 GMT


Sponsored Links
 Hi,

I am having problems with the Unit test framework. I have the
following files in the "tests" directory:


AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" http://schemas.android.com/apk/res/android" ;
    package="com.fryit.pkh.tests"
    >

    <application>
        <uses-library name="android.test.runner"/>
    </application>

    <instrumentation
android:name="android.test.InstrumentationTestRunner"
        android:targetPackage="com.fryit.pkh"
        android:label="Unit Tests"
    />
</manifest>


src/com/fryit/pkh/AllTests.java:
----------------------------------------

package com.fryit.pkh;

import junit.framework.Test;
import junit.framework.TestSuite;

import android.test.suitebuilder.TestSuiteBuilder;

public class AllTests extends TestSuite {
    public static Test suite() {
        return new TestSuiteBuilder(AllTests.class)
            .includeAllPackagesUnderHere()
            .build();
    }
}


src/com/fryit/pkh/test/SanityTest.java:
-------------------------------------------------

package com.fryit.pkh.test;

import junit.framework.Assert;

import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;


public class SanityTest extends AndroidTestCase {
    @SmallTest public void testSimpleAssert() throws Exception {
        assertTrue(true);
    }
}


After installing both the main app "com.fryit.pkh" and the tests
"com.fryit.pkh.tests", I try to run the tests, but get the following
error:

$ adb -e shell am instrument -w com.fryit.pkh.tests/
android.test.InstrumentationTestRunner
INSTRUMENTATION_RESULT: shortMsg=Unable to instantiate instrumentation
ComponentInfo{com.fryit.pkh.tests/
android.test.InstrumentationTestRunner}:
java.lang.ClassNotFoundException:
android.test.InstrumentationTestRunner in loader
dalvik.system.pathclassloa...@44e7a8b8
INSTRUMENTATION_RESULT: longMsg=java.lang.RuntimeException: Unable to
instantiate instrumentation ComponentInfo{com.fryit.pkh.tests/
android.test.InstrumentationTestRunner}:
java.lang.ClassNotFoundException:
android.test.InstrumentationTestRunner in loader
dalvik.system.pathclassloa...@44e7a8b8
INSTRUMENTATION_CODE: 0


Where am I going wrong?

Regards,
Keean.

--



Unit Tests

by Keean Schupke » Fri, 18 Dec 2009 00:28:45 GMT


 Found the problem, in the AndroidManifest:

<uses-library name="android.test.runner"/>

should be:

<uses-library android:name="android.test.runner"/>


Cheers,
Keean.


On Dec 17, 1:13pm, Keean Schupke <keean.schu...@googlemail.com>



--


Sponsored Links


Other Threads

1. root access for 300$? (dev phone)

So for those unlucky many who are stuck with a locked tight and pseudo
useless piece of computing machinery (i haz a phone hooked up to a
computer!1), simply because we followed the rules and didn't root our
phone before RC30, and then subsequently installed RC 30, are we left
to dry with a locked device?


of course not! for the low low price of 300$ and a little bit of shame
and  humility, we can purchase a dev phone and flash a custom RC30
with root access!  (is that the gist of iT? correct me if i'm wrong,
please), then we just have to find a sucker willing to purchase second
hand our first generation G1's off our hands.

And how long will it be until we start to see applications in the
marketplace which under the descriptor read "MUST HAVE DEVELOPER PHONE
WITH MOD'D RC30 TO RUN THIS!", just as we've seen with rooted apps.




Please, if somebody can see the silver lining in this cloud, because
I'm wondering when I can put my pants back on.
--~--~---------~--~----~------------~-------~--~----~

2. List View + downloading image in a background thread

Hello -

I'm trying to figure out the best design pattern to use here.

I have a list view, for which each row consists of some text and an
image. This content must be downloaded from the web. Currently, the
list view is using a custom adapter, and I implemented the getView()
method to dynamically download the image as it is needed (i.e. as the
row on which it should be displayed becomes visible).

This is all happening in the main thread, and it's having an impact on
the user experience. So I'd like to move the downloading of the image
to the background thread. I know how to do this ... but my quandary is
then, how do I pass the image information back to the main UI thread.
AFAIK, the most convenient way to pass information between threads is
using Handler.sendMessage() and including a bundle with the message
containing any information. But I don't think it's possible to include
an Image as part of a bundle, because it's not serializable.

Do I need to write the image to disk and pass a string containing the
file path? what are some other ways I could go about passing
information about a downloaded image from the non-UI background thread
to the ui thread?

Thanks!
Dan
--~--~---------~--~----~------------~-------~--~----~

3. Timeout executing service

4. List View + downloading image in a background thread

5. Launch Voice Dial From Bluetooth Headset Button

6. AW: How does a Cursor work?

7. T-mobile G-1 new Contract