標籤:rgb targe style rar lod htm round 日誌 strong
相應若水老師的第十四課
一,Log日誌輸出
Log.v(tag,message); //verbose模式,列印最具體的日誌
Log.d(tag,message); //debug層級的日誌
Log.i(tag,message); //info層級的日誌
Log.w(tag,message); //warn層級的日誌
Log.e(tag,message); //error層級的日誌
tag用來標記log訊息的源頭用常量來表示.message是這條log的內容.
二,單元測試
step1:在androidmanifest.xml中加入下面配置資訊:
<!-- <application> 中:--><uses-library android:name="android.test.runner"/><!-- </application> 之後: --><instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.example1.sqlitedemo" android:label="Testing"/> <!--注意!!android:targetPackage中要與項目名字一樣才幹執行成功!-->
step2寫單元測試代碼
比較好的方法是在項目中建立一個source floderz在裡面寫好要測試的單元檔案,並給它加入到AndroidTestCase中去:
public class PersonDAOTest extends AndroidTestCase {private static final String TAG = "PersonDAOTest";public void testAdd() //要測試的方法{Log.i(TAG,"Test");}public void testDelete() //要測試的方法{fail("Not yet implemented");}}測試時選中測試的類中的某個方法右鍵RunAS->android junit test
junit表單有綠條就表示測試能通過.紅色就有問題
三,調試
debug比較簡單,自己上手摸索.
附:
對Android應用進行單元測試
android學習筆記(9)android程式調試學習