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. File Access Error.

Hi all,

I have made a simple game application that saves to a file named
"scores.txt" (no prizes for guessing what it saves there..). The
activity containing the actual game does the saving, and I am trying
to access the file and display its contents from the main menu
activity.

However when I attempt to open the file I get the error:
11-28 17:13:59.617: ERROR/I/O ERROR(193): Error when trying to access
scores.txt - java.lang.IllegalStateException: The specified child
already has a parent. You must call removeView() on the child's parent
first.

I'm not sure what this means, as I get this error whether I have gone
straight to open the scores.txt file, or I have played the game first,
then tried to open the file.

If it is relevant, I have used mode 0, or MODE_PRIVATE on the
fileoutputstream in the "game" activity, however I don't think this
should make much difference as I am told by the documentation that:

"File creation mode: the default mode, where the created file can only
be accessed by the calling application (or all applications sharing
the same user ID)."

Though I am in a different activity, the application remains the
same...

Any help would be much appreciated! :)
--~--~---------~--~----~------------~-------~--~----~

2. Gallery setScrollIndicators

Hi,

 I want to have right and left scrolll indicators which will scroll
the gallery. I searched and found that earlier version of SDK had
Gallery.setScrollIndicators(View, View) but its not there anymore.
What is the suggested alternative? I will appreciate any advice/
pointers?

Regards,
Amit.

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

3. Open a HTML file

4. Can i write android code without activity (just with service)

5. Minimum PC Requirement for Using Android SDK

6. Keeping network connection alive when paused - Service?

7. Porting android to omap 2430