当前位置: 代码迷 >> Android >> Android 对施用进行单元测试
  详细解决方案

Android 对施用进行单元测试

热度:71   发布时间:2016-05-01 12:54:39.0
Android 对应用进行单元测试

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="org.soai.app"    android:versionCode="1"    android:versionName="1.0" >    <uses-sdk android:minSdkVersion="8" />    <application        android:icon="@drawable/ic_launcher"        android:label="@string/app_name" >        <activity            android:label="@string/app_name"            android:name=".MainActivity" >            <intent-filter >                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>                <uses-library android:name="android.test.runner"/>    </application> <instrumentation android:name="android.text.InstrumentationTestRunner" android:targetPackage="org.soai.app" android:label="Tests for My app"/></manifest>


 

测试类:需要继承AndroidTestCase类

public class FileServiceTest extends AndroidTestCase {     private static final String TAG = "FileServiceTest";     public void testRead() throws Throwable{     FileService service = new FileService(this.getContext());     String result = service.read("test.txt");     Log.i(TAG, result);     } }


 

  相关解决方案