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. Android application upgrade scenario

I have a pre-installed application on device, when user upgrades
application on pre-installed application, i want to show alert
something similar change log when user opens the application. In pre-
installed application, it's not  storing any version specific
information.Is there any way to recognize user is upgraded from the
pre-installed application?

I registered for PACKAGE_ADDED, PACKAGE_REMOVED and PACKAGE_REPLACED
intents. I am able to receive those intents when i try read the
version name it's not able read the version name when application is
removed. Any suggestions please?

-- 

2. MapActivity (MapView) Problem

I have a DROID using Android 2.2

I am attempting to get the simplest MapActivity to run on the device.
(NetBeans latest and greatest using a Google Api build target.)

I have all the appropriate Manifest entries, the simplest OnCreate ---

When it runs; the screen goes black for a few seconds then an error
dialog saying it stopped.
The problem seems to be WAY INSIDE map object.
Any suggestions would be most welcome.

The (poignant parts of the) log  -->

E/AndroidRuntime(24224): FATAL EXCEPTION: main
E/AndroidRuntime(24224): java.lang.NullPointerException
E/AndroidRuntime(24224):        at
com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:
71)
E/AndroidRuntime(24224):        at
com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:
61)
E/AndroidRuntime(24224):        at
com.google.android.maps.MapView.onLayout(MapView.java:681)
E/AndroidRuntime(24224):        at android.view.View.layout(View.java:7035)
E/AndroidRuntime(24224):        at
android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime(24224):        at android.view.View.layout(View.java:7035)
E/AndroidRuntime(24224):        at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
E/AndroidRuntime(24224):        at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
E/AndroidRuntime(24224):        at
android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
E/AndroidRuntime(24224):        at android.view.View.layout(View.java:7035)
E/AndroidRuntime(24224):        at
android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime(24224):        at android.view.View.layout(View.java:7035)
E/AndroidRuntime(24224):        at
android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
E/AndroidRuntime(24224):        at
android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
E/AndroidRuntime(24224):        at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(24224):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(24224):        at
android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(24224):        at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(24224):        at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(24224):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(24224):        at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(24224):        at dalvik.system.NativeStart.main(Native
Method)

-- 

3. USB Host Support (USB mass storage)

4. New to Android and programming

5. Contents of List view (using a cursor adapter) are not updated \ refreshed

6. Newbie

7. Why does Lattitude increase partial wake usage so much?