<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    qileilove

    blog已經轉移至github,大家請訪問 http://qaseven.github.io/

    使用Junit對Android應用進行單元測試

      在本文中,你將會學習到如何在Eclipse中創建Android JUnit單元測試工程以及在不同的條件下創建及運行自動測試用例

      準備工作

      本文假設讀者已經有一定的Android基礎知識,并且已經安裝了Eclipse和Android SDK等開發工具。本文將指導讀者如何將Android Junit框架應用到Android應用中去。本文還特別重點展示了如何測試Android中的Activity和如何識別程序中的錯誤。

      本文的示例代碼可以在http://code.google.com/p/simple-calc-unit-testing/中下載

      步驟1 被測試的應用SimpleCalc概況

      在本文中,將以一個寫好了的應用SimpleCalc簡單計算器為例子進行講解。這個簡單計算器有兩個功能,允許用戶輸入兩個數并將它們相加或相乘,最后顯示結果,如下圖所示:


      步驟2 SimpleCalc的的界面設計

      由于應用比較簡單,只占一屏,所以我們在/res/layout/main.xml中設計如下代碼所示:

    <linearlayout p="" <="" xmlns:android="http://schemas.android.com/apk/res/android" style="line-height: normal !important;">
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <textview p="" <="" android:layout_width="fill_parent" style="line-height: normal !important;">
    android:layout_height="wrap_content" android:text="@string/hello"
    android:gravity="center_horizontal" android:textSize="48px"
    android:padding="12px" />
    <edittext p="" <="android:id="@+id/value1" android:layout_height="wrap_content" style="line-height: normal !important;">
    android:hint="@string/hint1" android:inputType="numberDecimal"
    android:layout_width="fill_parent" android:textSize="48px">
    <edittext p="" <="android:id="@+id/value2" android:layout_height="wrap_content" style="line-height: normal !important;">
    android:hint="@string/hint2" android:inputType="numberDecimal"
    android:layout_width="fill_parent" android:textSize="48px">
    <framelayout p="" <="android:id="@+id/FrameLayout01" style="line-height: normal !important;">
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:padding="12px" android:background="#ff0000">
    <linearlayout p="" <="" android:id="@+id/LinearLayout02" style="line-height: normal !important;">
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:orientation="horizontal" android:background="#000000"
    android:padding="4px">
    <textview p="" <="" android:layout_width="wrap_content" style="line-height: normal !important;">
    android:layout_height="wrap_content" android:text="@string/resultLabel"
    android:textSize="48px" android:id="@+id/resultLabel">
    <textview p="" <="" android:layout_width="wrap_content" style="line-height: normal !important;">
    android:layout_height="wrap_content" android:id="@+id/result"
    android:textSize="48px" android:textStyle="bold"
    android:layout_marginLeft="16px">
    <linearlayout p="" <="" android:id="@+id/LinearLayout03" style="line-height: normal !important;">
    android:layout_height="wrap_content" android:layout_width="fill_parent">
    <button p=" android:id="@+id/addValues" android:layout_height="wrap_content">
    android:text="@string/add" android:textSize="32px"
    android:layout_width="wrap_content">
    <button p="" <=" android:id="@+id/multiplyValues" android:layout_height="wrap_content">
    android:text="@string/multiply" android:textSize="32px"
    android:layout_width="wrap_content">

      簡單解析一下這個界面設計,我們使用了LinearLayout,以使得控件能在垂直方向豎向排列。界面中包括了顯示標題“Unit Testing Sample”的textview,兩個輸入數字的edittext控件,一個FrameLayout控件中包含了一個水平的LinearLayout,在這個LinearLayout包含了一個顯示結果的textview以及其提示文字“Result”,注意的是FrameLayout的背景顏色設置為紅色,而LinearLayou設置成了黑色背景。

    posted on 2013-08-27 10:36 順其自然EVO 閱讀(238) 評論(0)  編輯  收藏 所屬分類: android

    <2013年8月>
    28293031123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導航

    統計

    常用鏈接

    留言簿(55)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 成人福利免费视频| 色猫咪免费人成网站在线观看| 精品亚洲AV无码一区二区三区| 亚洲一区二区三区不卡在线播放| 99久久免费观看| 久久久久国色AV免费看图片| 国产一级大片免费看| 国产亚洲情侣一区二区无| 久久亚洲国产视频| 麻豆狠色伊人亚洲综合网站| 一进一出60分钟免费视频| 国产精品免费观看调教网| 免费毛片在线播放| 亚洲人成色77777在线观看大 | 99ee6热久久免费精品6| 久久亚洲国产视频| 亚洲一级毛片免费看| 亚洲精品一级无码中文字幕| 一级毛片免费播放试看60分钟| 国产亚洲情侣一区二区无| 99久久久国产精品免费牛牛四川| 亚洲综合激情视频| 久久嫩草影院免费看夜色| 一个人在线观看视频免费| 国产AV无码专区亚洲AV男同| 亚洲国产成人手机在线观看| 国产一级淫片a免费播放口| 国产免费观看黄AV片| 一个人免费播放在线视频看片| 亚洲成a人片在线观看无码| 亚洲性线免费观看视频成熟 | 久久综合国产乱子伦精品免费| 激情内射亚洲一区二区三区| 岛国岛国免费V片在线观看 | 中文字幕亚洲无线码| 亚洲国产aⅴ成人精品无吗| 亚洲不卡AV影片在线播放| 亚洲av无码一区二区三区四区| 可以免费看黄的网站| 香港特级三A毛片免费观看| 最近2019中文字幕mv免费看|