Android Eclipse Plugin: Instrumentation Test Runner not specified

73,303

Solution 1

In the Run Configuration you may have Android JUnit Test, if there are any new launch configuration entries inside this, you delete it and then run your application it will run.

NOTE - This is likely to be the solution if you tried to run the test case before adding the correct lines to the manifest as described in the answer from Josef. If you have done this, delete the configuration (which will be complaining that no instrumentation test runner has been specified in its header) and then run it as an Android Junit Test again and it will create a valid configuration picking up the correct stuff that you have added to the manifest (see Josef's answer for this).

Solution 2

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>

Solution 3

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.)

Solution 4

Just do a right click on your test class from eclipse IDE and click on "Run As". After this select "run Configuration" which will launch a Confiuration Window in eclipse and you need to click on the radio button next to the "Instrumentation Runner" and select the configured Instrumentation Runner from the drop down. Now click on apply and then click on Run . I think this will solve your problem.

Thanks, Smruti

Solution 5

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.

Share:
73,303
Rob Stevenson-Leggett
Author by

Rob Stevenson-Leggett

I love to code and snowboard. Follow me on twitter: @rsleggett

Updated on July 08, 2022

Comments

  • Rob Stevenson-Leggett
    Rob Stevenson-Leggett almost 2 years

    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.

  • Jeb
    Jeb over 13 years
    and uses-library needs to be a child of application
  • Ring
    Ring about 12 years
    I got this error after I changed my package name in XML. Once I ran a clean (and android updated my run configurations) it fixed it.
  • Ian Newson
    Ian Newson about 12 years
    I'd upvote this twice if I could. Note to self: uses-library goes within the application element.
  • L. G.
    L. G. almost 10 years
    That's the right answer when you want to run one test class alone and you already have define instrumentation and uses-library in your manifest.
  • Android Killer
    Android Killer about 9 years
    for note : <instrumentation tag should be outside the application tag and <uses-library should be inside application tag.