首先是XML文件配置  

下面的包名要和自己的包名一致:

 

<?xml version="1.0" encoding="utf-8"?>  <manifest xmlns:android="http://schemas.android.com/apk/res/android"        package="com.jiangqq.log"        android:versionCode="1"        android:versionName="1.0">      <application android:icon="@drawable/icon" android:label="@string/app_name">      <uses-library android:name="android.test.runner"/>     <--重要配置          <activity android:name=".LogActivity"                    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-sdk android:minSdkVersion="7" />      <--   -重要配置-->        <instrumentation android:name="android.test.InstrumentationTestRunner"                 android:targetPackage="com.jiangqq.log"                 android:label="Tests for my app"/>    </manifest> 


下面是测试代码:
package com.jiangqq.log;     import android.test.AndroidTestCase;  import android.util.Log;  /**   * JunitRun-->LogTest(实例化)--》testSave()   * @author jiangqq   *   */  public class LogTest extends AndroidTestCase  {    private static final String TAG="LogTest";    public void testSave()throws Exception    {  int i=1+1;  Log.i(TAG, "result="+i);    }  }

截图效果: