Android 单元测试
来源:互联网 发布:哪个听书软件有诛仙 编辑:程序博客网 时间:2024/06/06 08:29
测试分类:
根据测试是否知道源代码:
黑盒测试:不知道源代码。只关心程序执行的过程和结果。 2-3 8k
白盒测试:根据源代码写测试方法。测试用例。需要写代码。和开发人员差不多。
根据测试的粒度:
方法测试: function test
单元测试:可以理解为unit test,某一块应用逻辑。
集成测试:intergration test
根据测试次数:
冒烟测试:smoke test 次数。Android 常用。
压力测试:pressure 请求量。
monkey -v 次数 -p 包名
一个简单的测试示例:
1. 编写测试方法。public void add()
2. 编写测试用例。CalcServiceTest extends AndroidTestCase
3. 配置AndroidMainfest 文件。
run as -android junit test 并在 Junit 窗口中查看。
项目结构:
CalcService.java
package com.serviatech.junit.service;public class CalcService {/** * 计算器相加的业务。 * * @param x * @param y * @return */public int add(int x, int y) {return x + y;}}
TestCalcService.java
package com.serviatech.junit.service.test;import com.serviatech.junit.service.CalcService;import android.test.AndroidTestCase;public class TestCalcService extends AndroidTestCase {/** * Add方法的测试代码,把异常抛给测试框架。 * * @throws Exception */public void testAdd() throws Exception {CalcService service = new CalcService();int result = service.add(3, 8);assertEquals(8, result);}}
结果:
0 0
- android 单元测试
- Android单元测试
- Android单元测试
- android单元测试
- Android单元测试
- Android单元测试
- android单元测试
- android单元测试
- Android单元测试
- Android单元测试
- android 单元测试
- android 单元测试
- Android--单元测试
- android单元测试
- Android单元测试
- Android单元测试
- Android单元测试
- ANDROID 单元测试
- 没有了祖国你将什么都不是邓
- 磁悬浮文胸屠
- Android开发性能优化简介
- cocos2d-x 源码分析 : Ref (CCObject) 源码分析 cocos2d-x内存管理策略
- javascript避免数字计算精度误差的方法之一
- Android 单元测试
- 解决cocos2d-x-3.1.1新建android工程
- Linux内核中的文件描述符
- Java线程:新特征-条件变量
- C++课程设计《工资管理系统》
- CareerCup Facebook Alex moving on a table
- 基于Spring MVC框架JSR-303的自定义注解Validator验证实现
- struts2中chain、redirect和redirectAction的区别
- 课程设计--模拟智能交通信号灯系统