Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 838
Android Killer Avatar asked Dec 21 '22 03:12

Android Killer


2 Answers

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.
like image 173
Lucifer Avatar answered Jan 05 '23 00:01

Lucifer


  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

like image 23
Vorsprung Avatar answered Jan 05 '23 02:01

Vorsprung