了解测试

来源:互联网 发布:linux i2c驱动 编辑:程序博客网 时间:2024/06/04 18:00

测试按照岗位划分可分为:

  • 黑盒测试:测试逻辑业务
  • 白盒测试:测试逻辑方法
按照测试粒度分为:
  • 方法测试:function test
  • 单元测试:unit test
  • 集成测试:integration test
  • 系统测试:system test
按测试暴力程度分为:
  • 冒烟测试:smoke test(让程序高负荷运行)
  • 压力测试:pressure test(对服务器测试)
单元测试:
junit
  Andorid Studio已经为我们生成了一个ApplicationTest,通常我们在目录下建立一个Test类继承InstrumentationTestCase
 
 可直接右键testclass(),Run'testclss()'
package com.example.administrator.junit;import android.test.InstrumentationTestCase;public class TestClass extends InstrumentationTestCase {    public void  testclass() throws Exception{        assertEquals(3,2);    }}
 也可在Run菜单栏中的Edit Configuration中具体设置。
 进行测试时通常创建一个类来写入需要测试的代码,再在测试类中进行测试:
package com.example.administrator.junit;public class Unit {    public static int add(int i , int j){        return  i-j;    }}
此处错误  ‘+’  写成了   ‘-’  ;
 
package com.example.administrator.junit;import android.test.InstrumentationTestCase;public class TestClass extends InstrumentationTestCase {    public void  testclass() {        int result = Unit.add(3,5);        //assertEquals用于检测实际值和期望值是否一致,针对有返回值类型        assertEquals(8,result);    }}
运行后报错:


0 0
原创粉丝点击