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. Eclipse IDE for Android platform development & android.jar

When I want to build a application ,in Eclipse, using
"android.opengl.Object3D" whereas it's not in SDK android.jar.
Then I checked the web-site "http://source.android.com/using-eclipse"
teaching you how to use whole android opensource in Eclipse and
debugging.

My questions are:
1. Is there any purpose that original SDK android.jar does not include
some packages ? for simplified use ?

2. Can I generate another (full set) JAR file to contain those
packages listed in "<android>/development/ide/eclipse/.classpath" ?

3. <Combined the Q1/Q2 above> For ex., in PC Eclipse env, If I want to
build an application utilized "android.opengl.Object3D", is there any
good step-by-step instructions to follow, and even refer to the whole
android framework classes such as "android.pim.DateUtils" ?

4. (Followed item2 above) When I open a new Java project with that
".classpath" on Eclipse and try to export that project as a JAR file,
I got several duplicate entry error and then failed, what could be the
wrong I made here ?


tks

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

2. How can i access System directory in an emulator ??

Hi all:
     It seemed that some work can  not be done due to permission
reasons unless my APK is  in installed in the System/app
directory ,So,is there any way i can do that ??
    Thanks in advance ~!
--~--~---------~--~----~------------~-------~--~----~

3. Google, thank you! (Android could make life for blind people easier)

4. Developing an IMS client on Android : Request for Comments

5. How to track menu navigation focus changes?

6. Stumped on launching Market app

7. how to Start onRunning Activity without restarting??