zoukankan      html  css  js  c++  java
  • AndroidTestCase测试用法

    1.    Java代码TestCase.java 继承AndroidTestCase类

    package com.test.casei;
    
     
    
    import android.test.AndroidTestCase;
    
    import android.util.Log;
    
     
    
    public class TestCase extends AndroidTestCase {
    
        private static final String TAG = "TestCase";
    
        @Override
    
        protected void setUp() throws Exception {
    
           super.setUp();
    
           Log.i(TAG, "[setUp]");
    
        }
    
       
    
        public void doWorkTest(){
    
           Log.i(TAG, "[doWorkTest]");
    
        }
    
       
    
        @Override
    
        protected void tearDown() throws Exception {
    
           super.tearDown();
    
           Log.i(TAG, "[tearDown]");
    
        }
    
    }
    
     

    2.    AndroidManifest.xml文件

    <?xml version="1.0" encoding="utf-8"?>
    
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    
        package="com.test.casei"
    
        android:versionCode="1"
    
        android:versionName="1.0" >
    
     
    
        <uses-sdk android:minSdkVersion="10" />
    
     
    
        <application
    
            android:icon="@drawable/ic_launcher"
    
            android:label="@string/app_name" >
    
            <uses-library android:name="android.test.runner" /><!-- 为测试添加  android.test.runner-->
    
           
    
        </application>
    
       
    
        <!-- 为测试添加 android.test.InstrumentationTestRunner -->
    
        <instrumentation
    
                    android:name="android.test.InstrumentationTestRunner"
    
                    android:targetPackage="com.test.casei"
    
                    android:label="test"
    
                    /> 
    
    </manifest>

    3.    TestCase.java流程

    setup()------>doWorkTest()---->tearDown()
  • 相关阅读:
    poj2263
    poj2304
    低调是态度,也是智慧
    股票操作記錄2
    治病記錄(2013年)
    过年了
    治病記錄
    近段時間學習記錄
    新的一年
    關于設計
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/4741302.html
Copyright © 2011-2022 走看看