Related concepts of testing
根据是否知道源代码测试可以分为黑盒和白盒。
黑盒:功能测试。
白盒:知道源代码,要写测试代码。
根据测试的粒度。
方法测试:
单元测试:
集成测试:
系统测试:
根据测试的暴力程度。
压力测试:谷歌工程师给我们提供了一个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的更多相关文章
- windows volume related concepts
Volume --- 一个volume就是一个分区. 在该“物理硬盘”上创建一个或多个分区,再创建文件系统,才可以得到一个VOLUME.此时VOLUME相对于主机是一个逻辑设备. https://m ...
- Building the Testing Pipeline
This essay is a part of my knowledge sharing session slides which are shared for development and qua ...
- Unit Testing with NSubstitute
These are the contents of my training session about unit testing, and also have some introductions a ...
- Hash function
Hash function From Wikipedia, the free encyclopedia A hash function that maps names to integers fr ...
- Learning WCF Chapter2 Service Contracts
A service contract describes the operations supported by a service,the message exchange pattern they ...
- State of Serverless
Some quick thoughts from Serverlessconf, Austin in April 2017 I wanted to take a bit of time to writ ...
- mvc3 学习链接收集
原文发布时间为:2011-04-17 -- 来源于本人的百度文章 [由搬家工具导入] The mvc3 study links collection http://dotnetslackers.com ...
- 【转】Artificial Neurons and Single-Layer Neural Networks
原文:written by Sebastian Raschka on March 14, 2015 中文版译文:伯乐在线 - atmanic 翻译,toolate 校稿 This article of ...
- Concurrency vs. Parallelism
http://getakka.net/docs/concepts/terminology Terminology and Concepts In this chapter we attempt to ...
随机推荐
- asp.net mvc 安全测试漏洞 " HTTP 动词篡改的认证旁路" 问题解决
IBM Security Appscan漏洞筛查-HTTP 动词篡改的认证旁路漏洞,具体解决方案: 在Web.Config中system.webServer节点增加配置security: <se ...
- Java访问文件夹中文件的递归遍历代码Demo
上代码: import java.io.File; /* * 需求:对指定目录进行所有内容的列出(包含子目录中的内容) * 也可以理解为 深度遍历. */ public class FindAllFi ...
- SQL Server性能优化(12)非聚集索引的组合索引存储结构
一,非聚集索引组合索引 用户可以在多个列上建立索引,这种索引叫做复合索引(组合索引).但复合索引在数据库操作期间所需的开销更小,可以代替多个单一索引.当表的行数远远大于索引键的数目时,使用这种方式可以 ...
- Java并发编程笔记之ReentrantLock源码分析
ReentrantLock是可重入的独占锁,同时只能有一个线程可以获取该锁,其他获取该锁的线程会被阻塞后放入该锁的AQS阻塞队列里面. 首先我们先看一下ReentrantLock的类图结构,如下图所示 ...
- APUE习题3.2用dup实现dup2以及shell中重定向符号的使用
习题3.2的要求是不使用fcntl()而编写一个同dup2()功能相同的函数.直觉上是不断使用dup()直到返回指定的文件描述符. #include <stdio.h>#include & ...
- postman传递对象到spring controller的方式
1.spring Controller @RestController @RequestMapping(value = "/basic/task") public class Ta ...
- 基于vue2.0实现仿百度前端分页效果(一)
前言 最近在接手一个后台管理项目的时候,由于之前是使用jquery+bootstrap做的,后端使用php yii框架,前后端耦合在一起,所以接手过来之后通过vue进行改造,但依然继续使用的boots ...
- JavaWeb学习 (十五)————JSP指令
一.JSP指令简介 JSP指令(directive)是为JSP引擎而设计的,它们并不直接产生任何可见输出,而只是告诉引擎如何处理JSP页面中的其余部分. 在JSP 2.0规范中共定义了三个指令: pa ...
- netty源码解解析(4.0)-7 线程模型-IO线程EventLoopGroup和NIO实现(二)
把NIO事件转换成对channel unsafe的调用或NioTask的调用 processSelectedKeys()方法是处理NIO事件的入口: private void processSelec ...
- [NOI 2015]品酒大会
Description 题库链接 \(n\) 杯鸡尾酒排成一行,其中第 \(i\) 杯酒 (\(1 \leq i \leq n\)) 被贴上了一个标签 \(s_i\),每个标签都是 \(26\) 个小 ...