根据是否知道源代码测试可以分为黑盒和白盒。

黑盒:功能测试。

白盒:知道源代码,要写测试代码。

根据测试的粒度。

方法测试:

单元测试:

集成测试:

系统测试:

根据测试的暴力程度。

压力测试:谷歌工程师给我们提供了一个monkey + 次数指令可以进行压力测试。

冒烟测试:

在Android工程下创建了一个这样的类,运行的时候有异常。

 package com.example.unit;

 public class Test {

     /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("哈哈");
} }

Invalid layout of java.lang.String at value
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (javaClasses.cpp:136), pid=4608, tid=3764
# fatal error: Invalid layout of preloaded class
#
# JRE version: (7.0_72-b14) (build )
# Java VM: Java HotSpot(TM) Client VM (24.72-b04 mixed mode windows-x86 )
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\android\adt-bundle-windows-x86-20131019\workspace\单元测试\hs_err_pid4608.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#

分析:Android工程是运行在Dalivk虚拟机上的,是运行在手机里面的,手机里面谷歌封装了一个Dalivk虚拟机,这段代码是java代码是运行在JVM上的,所以会挂掉。

要进行单元测试,Android中需要继承 AndroidTestCase这个类。

 package com.example.unit;

 import android.test.AndroidTestCase;

 public class CalcTest extends AndroidTestCase {
public void testAdd() {
Calc calc = new Calc();
int result = calc.add(3, 5);
assertEquals(8, result);
}
}

如果直接运行上面的代码会报异常,does not specify a android.test.InstrumentationTestRunner instrumentation or does not declare uses-library android.test.runner in its AndroidManifest.xml(没有指定android.test。在其AndroidManifest.xml文件中,未声明use -library android.test.runner)需要在清单文件里面配置函数库。

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.unit"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="cn.example.unit" android:label="Tests for My App" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="android.test.runner" />
<activity
android:name="com.example.unit.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> </application> </manifest>

<uses-library android:name="android.test.runner" /> 这段代码的作用是告诉系统我要用到系统的一些函数库。

 <instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="cn.example.unit" android:label="Tests for My App" />

这行代码的作用是:指定我要测试哪个应用。

如果说ppt搞丢了,找不到需要配置的东西,可以创建针对当前需要测试的工程,搞一个测试工程,测试工程的清单文件里面会将这两项配置自动更新出来。

Related concepts of testing的更多相关文章

  1. windows volume related concepts

    Volume --- 一个volume就是一个分区.  在该“物理硬盘”上创建一个或多个分区,再创建文件系统,才可以得到一个VOLUME.此时VOLUME相对于主机是一个逻辑设备. https://m ...

  2. Building the Testing Pipeline

    This essay is a part of my knowledge sharing session slides which are shared for development and qua ...

  3. Unit Testing with NSubstitute

    These are the contents of my training session about unit testing, and also have some introductions a ...

  4. Hash function

    Hash function From Wikipedia, the free encyclopedia   A hash function that maps names to integers fr ...

  5. Learning WCF Chapter2 Service Contracts

    A service contract describes the operations supported by a service,the message exchange pattern they ...

  6. State of Serverless

    Some quick thoughts from Serverlessconf, Austin in April 2017 I wanted to take a bit of time to writ ...

  7. mvc3 学习链接收集

    原文发布时间为:2011-04-17 -- 来源于本人的百度文章 [由搬家工具导入] The mvc3 study links collection http://dotnetslackers.com ...

  8. 【转】Artificial Neurons and Single-Layer Neural Networks

    原文:written by Sebastian Raschka on March 14, 2015 中文版译文:伯乐在线 - atmanic 翻译,toolate 校稿 This article of ...

  9. Concurrency vs. Parallelism

    http://getakka.net/docs/concepts/terminology Terminology and Concepts In this chapter we attempt to ...

随机推荐

  1. Java学习笔记36(File类)

    File类可以对操作系统中的文件进行操作: File类的静态成员变量: package demo; import java.io.File; public class FileDemo { publi ...

  2. Docker - 国内镜像的配置及使用

    Docker国内镜像 DaoCloud - Docker加速器 阿里云 - 开发者平台 微镜像 - 希云cSphere 网易蜂巢 阿里云的Docker加速器 阿里云 - 开发者平台:https://d ...

  3. FF笔试题整理

    一.选择题 1.怎样能唯一确定一颗二叉树? [解析] 只要知道中序遍历顺序,再加上其余两个遍历中任意一个都可以唯一确定一个二叉树.如果不知道中序遍历顺序,则无法确定. [反例] A-B-C,A是跟,B ...

  4. 从零开始学 Web 之 CSS3(一)CSS3概述,选择器

    大家好,这里是「 从零开始学 Web 系列教程 」,并在下列地址同步更新...... github:https://github.com/Daotin/Web 微信公众号:Web前端之巅 博客园:ht ...

  5. 谈谈对JVM的理解

            JVM可谓是学习JAVA基础中的基础了,但仍有不少同学对JVM概念还是比较模糊,甚至没有听说过,对java的理解也只是在基础语法 层面,本文就将对JVM进行初步介绍,因篇幅所限,只能介 ...

  6. Kafka的Log存储解析

    引言 Kafka中的Message是以topic为基本单位组织的,不同的topic之间是相互独立的.每个topic又可以分成几个不同的partition(每个topic有几个partition是在创建 ...

  7. 红黑树深入剖析及Java实现

    红黑树是平衡二叉查找树的一种.为了深入理解红黑树,我们需要从二叉查找树开始讲起. BST 二叉查找树(Binary Search Tree,简称BST)是一棵二叉树,它的左子节点的值比父节点的值要小, ...

  8. SpringMVC教程4

    SpringMVC教程3 一.数据回写 数据回写:在做数据更新的时候服务端查询的数据自动填充到表单中. 1.1默认方式 通过前面讲解的 Map Mode ModelMap绑定数据 @RequestMa ...

  9. Jquery Ajax 调用后台并返回数据

    一.前台调用ajax并解析json对象. $.ajax({ url : '', type : 'POST', //GET data : '’, beforeSend : function(reques ...

  10. Hadoop HDFS 设计随想

    目录 引言 HDFS 数据块的设计 数据块应该设置成多大? 抽象成数据块有哪些好处? 操作块信息的命令 HDFS 中节点的设计 有几种节点类型? 用户如何访问 HDFS? 如何对 namenode 容 ...