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

黑盒:功能测试。

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

根据测试的粒度。

方法测试:

单元测试:

集成测试:

系统测试:

根据测试的暴力程度。

压力测试:谷歌工程师给我们提供了一个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. 修改idea打开新窗口的默认配置

    使用idea开发maven项目时,发现使用新窗口创建一个项目时,例如file-settings的maven库配置都是用的用户下的maven库,如何配置一个全局的maven配置呢,操作如下: File- ...

  2. 自动化测试 selenium 环境搭建

    做 web 项目,测试是无法避免的.对于某些特定功能,采用单元测试就行.但如果想对网站进行整体测试,人工点击测试可行但有点累,如果能借助自动化测试工具就更好了.selenium 就是一款能满足这样要求 ...

  3. [每天解决一问题系列 - 0012] 如何通过程序获取IIS站点信息

    问题描述: 在WiX中需要判断某个站点是否存在,WiX没有这个能力,该怎么做呢? 解决方案: 解决方法就是写一个Custom Action来检测,实现的途径也有很多,现在想到了这么几个 1)Power ...

  4. 关于jQuery的一些东西

    1.jQuery的选择器学习     基本选择器        id选择器            $("#id名") 返回的是存储了指定的HTML元素对象的数组        标签 ...

  5. 从零开始学 Web 之 CSS3(七)多列布局,伸缩布局

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

  6. transformer 源码

    训练时: 1. 输入正确标签一次性解码出来 预测时: 1. 第一次输入1个词,解码出一个词 第二次输入第一次输入的词和第一次解码出来词一起,解码出来第3个词,这样依次解码,解码到最长的长度或者< ...

  7. linux搭建sftp服务器

    转自:http://blog.csdn.net/superswordsman/article/details/49331539 最近工作需要用到sftp服务器,被网上各种方法尤其是权限设置问题搞得晕头 ...

  8. python subprocess模块详解

    一.subprocess标准库 python执行shell脚本,通常会使用so模块中的几个方法,如system.spawn*.popen等.subprocess标准库的引入就是为了取代这些老的模块方法 ...

  9. 年终培训关于磁盘冗余阵列、热备、群集、负载均衡、云计算、F5、Nginx等的概念和基本原理

    在系统部署实施过程中,客户往往会关注系统的可用性方面的指标. 对于一个具备高可用性的系统来说, 多机部署方案是必不可少的. 我们这个知识分享,就从多个不同层面来介绍多机部署方案. ---------- ...

  10. SpringMVC教程3

    SpringMVC教程2 一.文件上传 1.引入相关jar包 maven坐标 <!-- fileUpload 解析上传的文件用到的jar --> <dependency> &l ...