Android Eclipse Plugin: Instrumentation Test Runner not specified

Viewed 73380

I'm getting this error when trying to run unit tests from Eclipse with an Android Project. The list of Instrumentation Test Runners is empty in the Android preferences.

[2009-06-17 23:57:51 - MyApp] ERROR: Application does not specify a android.test.InstrumentationTestRunner instrumentation or does not declare uses-library android.test.runner

It's also annoyingly decided that because I tried to run a unit test once, that's what I always want to do.

7 Answers

You're probably missing the uses-library and instrumentation nodes in your AndroidManifest.xml:

<manifest ...>
    <application ...>
        <!-- ... -->
        <uses-library android:name="android.test.runner" />
    </application>
    <instrumentation android:name="android.test.InstrumentationTestRunner"
        android:targetPackage="your.package"
        android:label="your tests label" />
</manifest>

One thing I noticed in this discussion that might be tripping some people up is that you need to make sure the "instrumentation" element in your manifest is a child of "manifest" and not of "application." (The examples here are correct, but this easy to mix up.)

http://developer.android.com/guide/topics/manifest/instrumentation-element.html

If you put your instrumentation stuff inside application, it won't be picked up, and your choices in the Eclipse ADT plugin for instrumentation runner may be blank. (But no error is thrown or shown, etc.)

It's not in your code, it's just eclipse is a little buggy. In your run configurations it could be trying to run a jUnit test, but select Run Application and that error will go away.

The problem is when you created the project, you would have had a AVD, so these configuration would be missing. My suggested way is first create the AVD and then create the android project :).

If you would have already created the project and if does not have much code you have written I would suggest to delete it and create a new one.

Related