Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Unit Testing in Eclipse: "Failed to launch test"

I've just started trying to set up some unit testing in what is essentially my first android app. I've had a hell of a time finding resource for this, but ultimately was able to scrape together what I hoped was the right path forward.

First, this is what I've done.

In Eclipse, I right-clicked my project that I'd like to create a test project for. I selected AndroidTools -> New Test Project I filled out the necessary information selecting a location of ../MyApp/tests for the new project and selected MyApp as the project to test. Everything else was left as default.

While this was executing I received the below as an error:

[2011-04-01 08:13:02 - WPMSTest] R.java was modified manually! Reverting to generated version!

But everything seemed okay. I had a new source tree in my tests folder.

So I tried to execute it (first on hardware, then on the emulator) by RunAs -> Android jUnit test.

In both runs I received the below in my eclipse console:

[2011-04-01 08:23:04 - WPMSTest] Launching instrumentation android.test.InstrumentationTestRunner on device emulator-5554
[2011-04-01 08:23:04 - WPMSTest] Failed to launch test

My two manifest files:

WPMSTest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.WPMS.test"
  android:versionCode="1"
  android:versionName="1.0">

<instrumentation android:targetPackage="com.WPMS" android:name="android.test.InstrumentationTestRunner" />
<application android:icon="@drawable/icon" android:label="@string/app_name">

<uses-library android:name="android.test.runner" />
</application>

WPMS:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.WPMS"
  android:versionCode="1"
  android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher_wpms">
    <activity android:name=".WPMS"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>    

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

I'm hoping someone has seen something like this before and can shed some light on what I'm doing wrong. Please let me know if you need any more files and I'll be sure to post them.

Thanks!

like image 472
Brian Avatar asked Apr 01 '11 12:04

Brian


1 Answers

I was missing a TestSuite in my Test Project. Once I had my AllTests class extend TestSuite I got past the error.

like image 105
Brian Avatar answered Sep 22 '22 12:09

Brian