Android开发_2.测试

来源:互联网 发布:js闭包 编辑:程序博客网 时间:2024/06/09 18:30

1.测试分类

  • 1.1 测试
    • 黑盒测试
      不知道软件代码
    • 白盒测试
      指导应用程序的源代码
  • 1.2 测试的粒度
    • 单元测试 junit test
    • 集成测试 intergration test
    • 系统测试 system test
  • 1.3 测试的程度
    • 压力测试(pressure test)
    • 冒烟测试(smoke test)

2.详解

  • 2.1 白盒测试的常用工具
    monkey 猴子
  • 2.2 Junit测试
    需要把应用程序部署到手机或模拟器中,在daivik虚拟器中运行。
    • 1.业务方法
    • 2.编写测试类,继承AndroidTestCase 类
    • 3.AndroidManifest.xml配置
    <!-- 1.测试的指令集 -->    <instrumentation android:name="android.test.InstrumentationTestRunner"        android:targetPackage="com.zhl.test"  />        <!-- android:targetPackage测试的目标工程:当前工程 -->
 <application        android:allowBackup="true"        android:icon="@drawable/ic_launcher"        android:label="@string/app_name"        android:theme="@style/AppTheme"         >        <!-- 2.测试需要的jar包 -->        <uses-library android:name="android.test.runner"></uses-library>        <activity        ......        ......
  • 2.3 LogCat
    把应用程序的log和system.out.println()打印输出
    • 1.打印分类
      Log.v(tag,msg) //verbose 提醒 黑色
      Log.d(tag,msg) //debug 调试 蓝色
      Log.i(tag,msg) //info 信息 绿色
      Log.w(tag,msg) //warn 警告 黄色
      Log.e(tag,msg) //error 错误 红色
      Log.wtf(tag,msg) //what the fuck 重大异常 红色
      1. 过滤器
        左边,自己添加过滤器,可以根据tag、关键字、PID等过滤;
        右上方,可以根据Log级别,选择过滤,显示该级及以上的日志。