您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源單元測(cè)試工具 > junit
Android下junit單元測(cè)試、logCat的使用
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2013/12/16 9:25:25 ] 推薦標(biāo)簽:

  Android下junit單元測(cè)試
  軟件測(cè)試小知識(shí):
  根據(jù)測(cè)試是否知道源代碼:
  黑盒測(cè)試:只關(guān)心程序執(zhí)行的過程和結(jié)果
  白盒測(cè)試:根據(jù)源代碼寫測(cè)試方法或者測(cè)試用例。
  根據(jù)測(cè)試的粒度:
  方法測(cè)試:function test
  單元測(cè)試:unit test
  集成測(cè)試:intergration test
  根據(jù)測(cè)試的次數(shù):
  冒煙測(cè)試:smoke test(android 猴子)
  壓力測(cè)試:prssure test
  Android單元測(cè)試:
  1.Android測(cè)試類要繼承AndroidTestCase類
  2.寫測(cè)試方法,在測(cè)試方法內(nèi)使用斷言assert來測(cè)試要測(cè)試的方法
  3.在AndroidManifest.xml中,要設(shè)置
  <instrumentation
  android:name="android.test.InstrumentationTestRunner"
  android:targetPackage="com.lee.test" />
  和<uses-library android:name="android.test.runner" >
  4.確保adb連接正常。
  MyService.java

package com.lee.test.service;

public class MyService {

 /**
  * 計(jì)算器相加的業(yè)務(wù)
  * @param a
  * @param b
  * @return
  */
 public int add(int a,int b){
  return a+b;
 }
}

上一頁(yè)12345下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd