ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:31.77KB ,
资源ID:5914922      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-5914922.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(软件测试实验一.docx)为本站会员(聆听****声音)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

软件测试实验一.docx

1、软件测试实验报告一、实验目的Junit最初是有Erich Gamma和Kent Beck编写的一个回归测试框架(regression testing framework),为单元测试(Unit Test)的支持框架,用来编写和执行重复性的测试,即所谓的白盒测试,Junit是一套框架,继承TestCase类,就可以用Junit进行自动测试。本次实验就是用Junit框架编写测试用例,进行自动化的白盒测试。实验包括三道题目:1DoubleLinkList2NextDay3Vector二、实验要求1实验环境:Java JDK 1.7,eclipse;2在慕测平台提交实验结果;3提交一份Word版实验报

2、告到ftp,报告内容需包含实验代码;4本次实验提交截止日期为10月28号晚12点写周六晚12点。三、实验设备环境JDK 1.7Eclipse LunaEclemma四、实验内容与结果1DoubleLinkList测试类中定义双向链表,考虑清楚其分支情况;代码:importstaticorg.junit.Assert.*;import;importjava.util.ArrayList;importjava.util.Collection;importorg.junit.Test;/双向链表,拥有增加结点,按索引搜寻publicclassDoubleLinkedListTest Testpubl

3、icvoidtest() DoubleLinkedListdoubleLinkedList1=newDoubleLinkedList();doubleLinkedList1.clear();Objectobject=newObject();doubleLinkedList1.indexOf(object);doubleLinkedList1.add(object);doubleLinkedList1.indexOf(object);Collectioncollection=newArrayList();collection.add(1);collection.add(2);collection

4、.add(3);DoubleLinkedListdoubleLinkedList=newDoubleLinkedList(collection);/assertEquals(true, actual);assertEquals(true,doubleLinkedList.contains(1);assertEquals(false,doubleLinkedList.contains(null);assertEquals(3,doubleLinkedList.size();doubleLinkedList.add(4);doubleLinkedList.remove(4);doubleLinke

5、dList.remove();Strings=null;doubleLinkedList.remove(s);doubleLinkedList.add(null);doubleLinkedList.remove(s);assertEquals(1,doubleLinkedList.get(0);doubleLinkedList.add(0,999);doubleLinkedList.add(4,999);doubleLinkedList.remove(4);trydoubleLinkedList.entry(-1);catch(Exceptione) /TODO: handle excepti

6、ontrydoubleLinkedList.entry(5);catch(Exceptione) /TODO: handle exceptiondoubleLinkedList.add(null);assertEquals(4,doubleLinkedList.indexOf(null);assertEquals(0,doubleLinkedList.indexOf(999);assertEquals(-1,doubleLinkedList.indexOf(99);assertEquals(0,doubleLinkedList.lastIndexOf(999);assertEquals(4,d

7、oubleLinkedList.lastIndexOf(null);doubleLinkedList.remove(s);assertEquals(-1,doubleLinkedList.lastIndexOf(null);doubleLinkedList.repOK();doubleLinkedList.inList(doubleLinkedList.entry(0);doubleLinkedList.inList(doubleLinkedList.entry(1);doubleLinkedList1.inList(doubleLinkedList.entry(0);DoubleLinked

8、ListdoubleLinkedList2=null;doubleLinkedList1.repOK();Object objects= object;doubleLinkedList.toArray(objects);DoubleLinkedListdoubleLinkedList3=newDoubleLinkedList();Object objects1= object,object,object,object,object,object,object;doubleLinkedList.toArray(objects1);collection.clear();doubleLinkedLi

9、st3.addAll(0,collection);doubleLinkedList3.addAll(4,collection);doubleLinkedList1.addAll(1,collection);doubleLinkedList1.addAll(55,collection);/Class c = DoubleLinkedList.class;/Method methods = c.getDeclaredMethods();/for(Method m:methods)/System.out.println(m.getName();/assertEquals(true,doubleLin

10、kedList.entry(3).previous.repOK();2NextDay代码:DateTest:public class DateTest Testpublic void test() Date date = new Date(1, 2, 8);Date date1 = new Date(1, 31, 4);Date date2 = new Date(12, 31, 4);date.getDay();date.getMonth();date.getYear();date.increment();date1.increment();date2.increment();date.toS

11、tring();date.printDate();date.equals(date1);date.equals(date2);date.equals(null);date1.equals(date2);date.equals(date);DayTestpublicvoidgetDay()Year year=newYear(4);Month month1=newMonth(4,year);Day day=newDay(3,month1);Day day1=newDay(28,month1);assertEquals(day.getCurrentPos(), 3);day1.setCurrentP

12、os(32);assertEquals(day1.increment(),false);assertEquals(day.increment(),true);TestpublicvoidisValid1()tryMonth month=null;Year year1=newYear(11);Day day1=newDay(2,month);catch(Exception o)assertEquals(oinstanceofIllegalArgumentException,true);TestpublicvoidisValid2()tryYear year1=newYear(11);Month

13、month2=newMonth(10,year1);month2.setCurrentPos(13);Day day=newDay(2,month2);catch(Exception o)assertEquals(oinstanceofIllegalArgumentException,true);TestpublicvoidisValid3()tryYear year1=newYear(11);Month month2=newMonth(10,year1);Day day=newDay(-1,month2);catch(Exception o)assertEquals(oinstanceofI

14、llegalArgumentException,true);TestpublicvoidisValid4()tryYear year1=newYear(11);Month month2=newMonth(10,year1);Day day=newDay(35,month2);catch(Exception o)assertEquals(oinstanceofIllegalArgumentException,true);Testpublicvoidequals()Year year1=newYear(11);Month month2=newMonth(10,year1);Month month3

15、=newMonth(11,year1);Day day=newDay(3,month2);Day day1=newDay(4,month2);Day day2=newDay(4,month3);Day day3=newDay(4,month2);Object o=newObject();assertEquals(day.equals(o),false);assertEquals(day.equals(day1),false);assertEquals(day1.equals(day2),false);assertEquals(day1.equals(day3),true);assertEqua

16、ls(day.getDay(), 3);MonthTestpublicclassMouthTestMonthmonth =null;Yearyear =null;Testpublicvoidmonth() tryYearyear1 =newYear(6);Monthmonth2 =newMonth(6, year1);Monthmonth3 =newMonth(-3, year1);catch(Exception e) assertEquals(einstanceofIllegalArgumentException,true);Testpublicvoidmonth1() tryYearyea

17、r1 =newYear(6);Monthmonth2 =newMonth(15, year1);catch(Exception e) assertEquals(einstanceofIllegalArgumentException,true);Testpublicvoidmonth2() tryYearyear2 =newYear(-1);year2.setCurrentPos(0);Monthmonth5 =newMonth(7, year2);catch(Exception e) assertEquals(einstanceofIllegalArgumentException,true);

18、Testpublicvoidmonth3() tryMonthmonth5 =newMonth(7,year);catch(Exception e) assertEquals(einstanceofIllegalArgumentException,true);TestpublicvoidgetMonth() Yearyear1 =newYear(4);Yearyear2 =newYear(5);Monthm1 =newMonth(1, year1);Monthm2 =newMonth(1, year2);Monthm3 =newMonth(12, year2);assertEquals(m1.

19、getMonthSize(), 31);assertEquals(m2.getMonthSize(), 31);assertEquals(m1.getMonth(), 1);assertEquals(m3.increment(),false);assertEquals(m1.increment(),true);Testpublicvoidequals() Object o =newObject();Yearyear1 =newYear(4);Yearyear2 =newYear(5);Monthm1 =newMonth(1, year1);Monthm2 =newMonth(1, year2)

20、;Monthm3 =newMonth(2, year2);Monthm4 =newMonth(1, year1);assertEquals(m1.equals(m2),false);assertEquals(m1.equals(m3),false);assertEquals(m1.equals(o),false);assertEquals(m1.equals(m4),true);YearTestpublicclassYearTestYearyear1=newYear(1);Yearyear2=newYear(1);Yearyear3=newYear(2);Objects=newObject()

21、;TestpublicvoidgetYear()assertEquals(year1.getYear(), 1);Testpublicvoidincrement()Yearyear=newYear(-1);year.increment();year.increment();assertEquals(year1.increment(),true);Testpublicvoidequals()assertEquals(year1.equals(year2),true);assertEquals(year1.equals(year3),false);assertEquals(year1.equals

22、(s),false);TestpublicvoidisValid()tryYearyear0=newYear(0);catch(Exceptiono)assertEquals(oinstanceofIllegalArgumentException,true);TestpublicvoidisLeap()Yeara1=newYear(4);Yeara2=newYear(100);Yeara3=newYear(5);Yeara4=newYear(400);Yeara5=newYear(-1);Yeara6=newYear(-401);Yeara7=newYear(-2);Yeara8=newYea

23、r(-101);Yeara9=newYear(-5);assertEquals(a1.isLeap(),true);assertEquals(a2.isLeap(),false);assertEquals(a3.isLeap(),false);assertEquals(a4.isLeap(),true);assertEquals(a5.isLeap(),true);assertEquals(a6.isLeap(),true);assertEquals(a7.isLeap(),false);assertEquals(a8.isLeap(),false);assertEquals(a9.isLea

24、p(),true);3)VectorVector是一个可扩展容器测试类中创建vector实例代码:importstaticorg.junit.Assert.*;importjava.util.ArrayList;importjava.util.Collection;importorg.junit.Test;publicclassVectorTest Testpublicvoidtest() Vectorvector=newVector();Vectorvector4=newVector(1,2);tryVectorvector2=newVector(-1,1);catch(Exceptione

25、) assertEquals(true,einstanceofIllegalArgumentException);Collectioncollection=newArrayList();Objectobject1=newObject();Objectobject2=newObject();Objectobject3=newObject();collection.add(object1);collection.add(object2);Vectorvector3=newVector(collection);vector.ensureCapacity(2);vector3.ensureCapaci

26、ty(2);vector3.ensureCapacity(3);vector4.ensureCapacity(5);assertEquals(2,vector3.size();assertEquals(true,vector3.contains(object1);assertEquals(false,vector3.contains(null);assertEquals(0,vector3.indexOf(object1);vector3.setElementAt(object2, 1);tryvector3.setElementAt(object2, 2);catch(Exceptione)

27、 assertEquals(true,einstanceofArrayIndexOutOfBoundsException);vector3.removeElement(object2);vector3.removeElement(object3);vector3.addElement(object2);vector3.removeElementAt(1);vector3.get(0);tryvector3.get(2);catch(Exceptione) /TODO: handle exceptiontryvector3.removeElementAt(3);catch(Exceptione)

28、 /TODO: handle exceptiontryvector3.removeElementAt(-1);catch(Exceptione) /TODO: handle exceptionvector3.addElement(object2);vector3.addElement(object2);vector3.addElement(object2);vector3.removeElementAt(2);vector3.addElement(null);vector3.indexOf(null, 1);五总结与分析1.知识薄弱,测试类容易重复2.分支覆盖3.画树状图有利于分析代码教师评语:签名:日期:成绩:

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2