android學習筆記(9)android程式調試學習

來源:互聯網
上載者:User

標籤: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程式調試學習

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.