Android UnitTest FrameWork

來源:互聯網
上載者:User

標籤:android   style   blog   http   color   io   使用   ar   for   

  1. Android test suites基於Junit,可以直接使用Junit測試不使用android api的class,也可以使用android的Junit extensions測試android component
  2. android的Junit extensions提供了基於component的測試類別,這些類可以協助建立模擬物件,控制componetn的生命週期
  3. Android testing apid支援Junit3的code style,而不是Junit4
  4. Android instrumentation提供了方法可以調用android component的生命週期方法,如Activity的onCreate,onResume等
  5. 首先要把Junit.jar加到app的lib路徑下,再要測試的類上執行操作,會產生test類PieceImageTest,注意PieceImageTest沒有繼承任何類,這時候執行test方法會得到如下錯誤資訊:
    junit.framework.AssertionFailedError: No tests found in
    需要讓PieceImageTest繼承TestCase之後就可以運行test case了,測試方法名可以不用以test開頭




  6. Junit4 本身已經不要求測試類別要繼承自TestCase了,但在Android Studio中不繼承TestCase會拋出No tests found in的錯誤,另外Junit4.11 中不包含Hamcrest包,Hamcrest用於增強Junit測試能力

Android UnitTest FrameWork

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.