下载此文档

使用junit对android应用进行单元测试.docx


文档分类:IT计算机 | 页数:约17页 举报非法文档有奖
1/17
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/17 下载此文档
文档列表 文档介绍
使用Junit对Android应用进行单元测试
在本文中,你将会学习到如何在Eclipse中创建Android JUnit的单元测试工程以及在不同的条件下创建及运行自动测试用例。准备工作
本文假设读者已经有一定的Android基础知识,并且已经安装了Eclipse和Android SDK等开发工具。本文将指导读者如何将Android Junit框架应用到Android应用中去。本文还特别重点展示了如何测试Android中的Activity和如何识别程序中的错误。
本文的示例代码可以在http://code./p/simple-calc-unit-testing/中下载
步骤1 被测试的应用SimpleCalc概况
在本文中,将以一个写好了的应用SimpleCalc简单计算器为例子进行讲解。这个简单计算器有两个功能,允许用户输入两个数并将它们相加或相乘,最后显示结果,如下图所示:
步骤2 SimpleCalc的的界面设计由于应用比较简单,只占一屏,所以我们在/res/layout/:
<?xml version="" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas./apk/res/android"
    android:rientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="***@string/hello"
        android:gravity="center_horizontal" android:textSize="48px"
        android:padding="12px"
/>
<EditText android:layout_height="wrap_content" android:id="@+id/value1"
        android:hint="***@string/hint1" android:inputType="numberDecimal"
        android:layout_width="fill_parent" android:textSize="48px"></EditText>
<EditText android:layout_height="wrap_content" android:id="@+id/value2"
        android:hint="***@string/hint2" android:inputType="numberDecimal"
        android:layout_width="fill_parent" android:textSize="48px"></EditText>
<FrameLayout android:id="@+id/FrameLayout01"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:padding="12px" android:background="#ff0000">
<LinearLayout android:id="@+id/LinearLayout02"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:rientation="horizontal" android:background="#000000"
            android:padding="4px">
<TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="***@string/resultLabel"
                android:textSize="48px" android:id="@+id/result

使用junit对android应用进行单元测试 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数17
  • 收藏数0 收藏
  • 顶次数0
  • 上传人buhouhui915
  • 文件大小427 KB
  • 时间2018-05-04