how to run android unit test project

10,125

Solution 1

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.

Solution 2

  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

Solution 3

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

Share:
10,125
Android Killer
Author by

Android Killer

Android/java developer having 7+ experience. Love programming. So i am here in this great SO site. Started blog : https://programmingalltheway.wordpress.com/. Request to follow if someone wants.

Updated on June 09, 2022

Comments

  • Android Killer
    Android Killer about 2 years

    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.

  • didierc
    didierc over 9 years
    if it is not an answer, perhaps it would have been better to include it directly in the body of your question?
  • Android Killer
    Android Killer over 9 years
    @didierc if we will include in the body of the question, it is less readable. If we will add it as an answer, There will be more possibility that user will read it.