android unit test example

  1. Write a test class that inherits AndroidTestCase, and put this class under the test package independently. Under normal circumstances, write methods in this class, test the methods of your tool class, give input and get output, and display it in the form of Log.
  2. Add unit test configuration to AndroidManifest.xml. Specifically, first add it to the Application tag
    <uses-library android:name="android.test.runner"/>
     Add the instrumentation tag outside the Application tag
    <instrumentation
            android:targetPackage="com.phoobobo.robot"
            android:label="this is a test"
            android:name="android.test.InstrumentationTestRunner">        
    </instrumentation>
     Please set the package name and label to your own package name and name your label.
  3. Run the test. If you are using Eclipse, right-click the project name and select Run As Android JUnit Test.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326447547&siteId=291194637