Android Killer
Android Killer

Reputation: 18489

how to run android unit test project

I know this is silly question, but i am just stuck with this:

1.I have one main project called MainProject. 2. Inside that there is one test project which has its own source and menifest file and in menifest file i added all required to make it test project like this :

<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app.tests" android:versionCode="1"
    android:versionName="1.0">
    <application>
       <uses-library android:name="android.test.runner" />
    </application>
    <uses-sdk android:minSdkVersion="3" />

<instrumentation android:name="android.test.InstrumentationTestRunner"
       android:targetPackage="com.example.app" android:label="Tests for My App" />
</manifest>

Now i right click on it go to "Run As" and "Run Configuration" and select "Android JUnit Test" but it showing error:

MainProject does not specify a android.test.InstrumentationTestRunner instrumentation or does not declare uses-library android.test.runner in its AndroidManifest.xml

Any help plz?

There is one video link of @Lucifer below which is helpful and also my own answer which a link you can check which is also helpful.

Upvotes: 4

Views: 10156

Answers (3)

Lucifer
Lucifer

Reputation: 29632

Robotium is an Android test automation framework that has full support for native and hybrid applications. Robotium makes it easy to write powerful and robust automatic black-box test cases. With the support of Robotium, test case developers can write function, system and acceptance test scenarios, spanning multiple Android activities.

  • You can develop powerful test cases, with minimal knowledge of the application under test.
  • The framework handles multiple Android activities automatically.
  • Minimal time needed to write solid test cases.
  • Readability of test cases is greatly improved, compared to standard instrumentation tests.
  • Test cases are more robust due to the run-time binding to GUI components.
  • Fast test case execution.
  • Integrates smoothly with Maven or Ant to run tests as part of continuous integration.

Upvotes: 9

Android Killer
Android Killer

Reputation: 18489

I am giving answer to my own question,rather it is not a answer it is a link that you can find which is very nice and easy to understand how you can do android unit test using Robotium

Here is the link: LINK

Upvotes: 1

Vorsprung
Vorsprung

Reputation: 34327

  1. select File/new/project

  2. select Android Test Project

  3. give the Project a name

  4. select test target as the other project you already have, in your posting above "MainProject"

  5. pick the target platform, ie Android 4.0

  6. finish and the test project is made

  7. add classes under src in the test project that extend one of the android.test classes

Upvotes: 1

Related Questions