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 ...
随机推荐
- Kubernetes-2--安装部署
kubernetes的部署方式: 1,kubeadm 2, 二进制安装包部署 条件准备: 1,关闭系统的swap分区 为什么要关闭swap分区,我还没有去看官方的说明,搜索到的答案是 kubernet ...
- 用Nginx搭建IIS集群实现负载均衡
长话短说,我们用Nginx来搭建一个简单的集群,实现Web应用的负载均衡,架构图如下: 两台Web服务器,一台静态资源服务器,因为是演示,我们以网站形式部署在本机IIS中 一台Nginx代理服务器,安 ...
- Window安装Erlang环境
最近学习RabbitMQ,下载rabbitmq-server后,安装提示,需要erlang环境,接着又下载erlang安装包. 仅在这里提供下安装文件和环境配置方法. 1.rabiitmq-serve ...
- python的数据驱动
什么叫数据驱动? 登录用例 ->不用的用户名登录,但是自动化化脚本一样,虽然脚本相同,步骤相同,但是不同的用户名登录得出的数据是不一样的,于是就有了数据驱动,就是数据的改变驱动自动化测试的执行导 ...
- [源码]Dephi溢出demo( Shellcode for XP)
[源码]Dephi溢出demo( Shellcode for XP) unit Unit1; interface uses Windows, Messages, SysUtils, Variants, ...
- 批量去除文件的BOM头
<?php class KillBom{ //定义扩展名 public static $m_ext = ['txt','php','js','css']; /** * 传入一个任意文件,自动区分 ...
- 【转】ASP.NET Core MVC 配置全局路由前缀
本文地址:http://www.cnblogs.com/savorboard/p/dontnet-IApplicationModelConvention.html作者博客:Savorboard 前言 ...
- 获取DNS服务器的版本信息
1 如何获取DNS服务器的版本信息 向某个DNS服务器发送下面的请求即可获得版本信息 dig @115.124.17.156 version.bind chaos txt 它返回的信息如下: ; &l ...
- shiro教程1(HelloWorld)
shiro简介 官网 Apache Shiro是一个强大且易用的Java安全框架,执行身份验证.授权.密码和会话管理.使用Shiro的易于理解的API,您可以快速.轻松地获得任何应用程序,从最小的移动 ...
- 记一次安装Nginx+php-fpm安装后无法解析.php文件,状态码200,但显示空白页
安装环境: Nginx:Nginx1.12.2 PHP:PHP 7.2 系统:CentOS 7.4 安装方式: Nginx与PHP都是yum安装的,具体步骤: 1.安装epel源再安装Nginx: r ...