软件测试实验一.docx
- 文档编号:1436371
- 上传时间:2022-10-22
- 格式:DOCX
- 页数:15
- 大小:17.85KB
软件测试实验一.docx
《软件测试实验一.docx》由会员分享,可在线阅读,更多相关《软件测试实验一.docx(15页珍藏版)》请在冰豆网上搜索。
软件测试实验一
《软件测试》实验报告
一、实验目的
Junit最初是有ErichGamma和KentBeck编写的一个回归测试框架(regressiontestingframework),为单元测试(UnitTest)的支持框架,用来编写和执行重复性的测试,即所谓的白盒测试,Junit是一套框架,继承TestCase类,就可以用Junit进行自动测试。
本次实验就是用Junit框架编写测试用例,进行自动化的白盒测试。
实验包括三道题目:
1)DoubleLinkList
2)NextDay
3)Vector
二、实验要求
1)实验环境:
JavaJDK1.7,eclipse;
2)在慕测平台提交实验结果;
3)提交一份Word版实验报告到ftp,报告内容需包含实验代码;
4)本次实验提交截止日期为10月28号晚12点(写周六晚12点)。
三、实验设备(环境)
JDK1.7
EclipseLuna
Eclemma
四、实验内容与结果
1)DoubleLinkList
测试类中定义双向链表,考虑清楚其分支情况;
代码:
importstatic;
import;
import;
import;
import;//双向链表,拥有增加结点,按索引搜寻
publicclassDoubleLinkedListTest{
@Test
publicvoidtest(){
DoubleLinkedListdoubleLinkedList1=newDoubleLinkedList();
doubleLinkedList1.clear();
Objectobject=newObject();
doubleLinkedList1.indexOf(object);
doubleLinkedList1.add(object);
doubleLinkedList1.indexOf(object);
Collection
collection.add("1");
collection.add("2");
collection.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");
doubleLinkedList.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);
try{
doubleLinkedList.entry(-1);
}catch(Exceptione){
//TODO:
handleexception
}
try{
doubleLinkedList.entry(5);
}catch(Exceptione){
//TODO:
handleexception
}
doubleLinkedList.add(null);
assertEquals(4,doubleLinkedList.indexOf(null));
assertEquals(0,doubleLinkedList.indexOf("999"));
assertEquals(-1,doubleLinkedList.indexOf("99"));
assertEquals(0,doubleLinkedList.lastIndexOf("999"));
assertEquals(4,doubleLinkedList.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));
DoubleLinkedListdoubleLinkedList2=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();
doubleLinkedList3.addAll(0,collection);
doubleLinkedList3.addAll(4,collection);
doubleLinkedList1.addAll(1,collection);
doubleLinkedList1.addAll(55,collection);
//Class
>c=DoubleLinkedList.class;
//Method[]methods=c.getDeclaredMethods();
//for(Methodm:
methods){
//;
//}
assertEquals(true,doubleLinkedList.entry(3).previous.repOK());
}
}
2)NextDay
代码:
DateTest:
publicclassDateTest{
@Test
publicvoidtest(){
Datedate=newDate(1,2,8);
Datedate1=newDate(1,31,4);
Datedate2=newDate(12,31,4);
date.getDay();
date.getMonth();
date.getYear();
date.increment();
date1.increment();
date2.increment();
date.toString();
date.printDate();
date.equals(date1);
date.equals(date2);
date.equals(null);
date1.equals(date2);
date.equals(date);
}
}
DayTest
publicvoidgetDay()
{
Yearyear=newYear(4);
Monthmonth1=newMonth(4,year);
Dayday=newDay(3,month1);
Dayday1=newDay(28,month1);
assertEquals(day.getCurrentPos(),3);
day1.setCurrentPos(32);
assertEquals(day1.increment(),false);
assertEquals(day.increment(),true);
}
@Test
publicvoidisValid1()
{
try{
Monthmonth=null;
Yearyear1=newYear(11);
Dayday1=newDay(2,month);
}
catch(Exceptiono)
{
assertEquals(oinstanceofIllegalArgumentException,true);
}
}
@Test
publicvoidisValid2()
{
try{
Yearyear1=newYear(11);
Monthmonth2=newMonth(10,year1);
month2.setCurrentPos(13);
Dayday=newDay(2,month2);
}catch(Exceptiono)
{
assertEquals(oinstanceofIllegalArgumentException,true);
}
}
@Test
publicvoidisValid3()
{
try{
Yearyear1=newYear(11);
Monthmonth2=newMonth(10,year1);
Dayday=newDay(-1,month2);
}catch(Exceptiono)
{
assertEquals(oinstanceofIllegalArgumentException,true);
}
}
@Test
publicvoidisValid4()
{
try{
Yearyear1=newYear(11);
Monthmonth2=newMonth(10,year1);
Dayday=newDay(35,month2);
}catch(Exceptiono)
{
assertEquals(oinstanceofIllegalArgumentException,true);
}
}
@Test
publicvoidequals()
{
Yearyear1=newYear(11);
Monthmonth2=ne
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 软件 测试 实验
![提示](https://static.bdocx.com/images/bang_tan.gif)