软件工程测试实验.docx
《软件工程测试实验.docx》由会员分享,可在线阅读,更多相关《软件工程测试实验.docx(20页珍藏版)》请在冰点文库上搜索。
![软件工程测试实验.docx](https://file1.bingdoc.com/fileroot1/2023-7/13/32821300-ab31-4cc7-b37b-0c7419f619f3/32821300-ab31-4cc7-b37b-0c7419f619f31.gif)
软件工程测试实验
淮海工学院计算机科学系
实验报告书
课程名:
《软件工程》
题目:
软件测试实验
班级:
软件121
学号:
2012122722
姓名:
朱德坤
软件测试验报告要求
1目的与要求:
1)系统学习和理解结构化软件工程实现阶段的基本概念、原理、技术和方法;
2)掌握软件测试的基本技术和方法,特别是白盒测试与黑盒测试技术和方法;
3)通过实验,要逐步提高白盒测试与黑盒测试技术的实际应用能力;
4)熟悉C++编程环境下编写、调试单元代码的基本操作技术和方法;
5)按照实验题目要求独立完成本次试验任务,严禁拷贝、抄袭他人设计成果;
6)认真书写实验报告(要求给出完整的测试信息,如测试程序、测试用例,测试结果分析等),并于5月5日以前提交。
2实验容或题目
1.选择结构化详细设计试验中自己设计的某一具有代表性控制结构模块(含有分支和循环结构),并用C语言实现(提前准备好,每种测试用例分别写在作业本上,上机时带上检查),而后分别完成下述2、3、4各题测试用例设计和测试结果分析;
2.采用白盒测试技术中逻辑覆盖方法(至少包含语句覆盖、判定覆盖、条件覆盖、条件组合覆盖)设计测试用例,完成测试(测试屏幕截图)和测试结果分析;
3.采用白盒控制结构测试技术的基本路径测试和边界测试方法设计相应测试用例,并完成测试和测试结果分析;
4.采用黑盒测试技术中的等价类划分方法设计相应测试用例(可重选适合黑盒测试技术的模块),并完成程序测试和测试结果分析;
3实验步骤与源程序
程序流程图:
流图:
程序:
//拥有超级用户superuser,密码zdk
#include
#include
#include
#include
#include
usingnamespacestd;
intPD;//全局判断执行码
voidSetPos(inti,intj)//界面光标位置函数
{
COORDpos={i-1,j-1};
HANDLEOut=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(Out,pos);
}
voidjm()//绘制登陆界面
{
system("cls");
SetPos(20,3);
cout<<"**************************************";
SetPos(20,4);
cout<<"*欢迎使用图书管馆图书管理系统*";
SetPos(20,5);
cout<<"**************************************";
SetPos(30,7);
cout<<"1.注册";
SetPos(30,8);
cout<<"2.登录";
SetPos(30,9);
cout<<"3.退出";
SetPos(30,12);
cout<<"请输入对应功能的序号:
";
}
voidZjm()//绘制登录后界面
{
inti;
if(PD==0)
{
PD=1;
system("cls");
return;
}
SetPos(25,3);
if(PD==1)cout<<"1.查看我的图书信息";
elsecout<<"1.管理其他用户";
SetPos(25,4);
cout<<"2.退出";
SetPos(20,6);
cout<<"请输入序号:
";
cin>>i;
switch(i)
{
case1:
cout<<"图书信息:
....\n....\n....\n";
system("pause");
exit(0);//登陆后的执行区域,预留空间
case2:
PD=1;
system("cls");
return;
}
}
classuser//定义用户类
{
public:
user(stringw1,stringw2):
user1(w1),password(w2){}
voidsave()//保存成员函数
{
ofstreamofile("C:
\\ProgramFiles\\data.txt",ios_base:
:
app);
ofile<ofile.close();
}
private:
stringuser1;
stringpassword;
};
voidzhuce()//注册全局函数
{
charuser1[25],user2[25]="superuser",password[25],password1[25];
ofstreamofile;
ofile.open("C:
\\ProgramFiles\\data.txt",ios_base:
:
app);
ofile.close();
cout<<"请输入用户名:
";
cin>>user1;
if(strcmp(user1,user2)==0)
{
PD=0;
cout<<"您不能注册管理员";
Sleep(1000);
return;
}
ifstreamifile;
ifile.open("C:
\\ProgramFiles\\data.txt",ios_base:
:
in);
while(!
ifile.eof())
{
ifile.getline(user2,25,'\n');
ifile.getline(password,25,'\n');
if(strcmp(user1,user2)==0)
{
cout<<"该用户已存在";
Sleep(1000);
ifile.close();
PD=0;
return;
}
}
ifile.close();
Set:
cout<<"请输入密码:
";
cin>>password;
cout<<"请再次输入密码:
";
cin>>password1;
if(strcmp(password,password1)!
=0)
{
cout<<"您两次输入的密码不一致!
"<system("pause");
gotoSet;
}
useruse(user1,password);
use.save();
cout<"<Sleep(1000);
system("cls");
PD=0;
}
voiddenglu()//登陆函数
{
charuser[25],password[25];
charuser1[25]="superuser",password1[25]="zdk";
cout<<"\t\t请输入用户名:
";
cin>>user;
cout<<"\t\t请输入密码:
";
cin>>password;
if(strcmp(user1,user)==0&&strcmp(password,password1)==0)
{
cout<<"\t\t\t登陆成功";
Sleep(1000);
PD=2;
system("cls");
cout<<"欢迎管理员登录!
";
return;
}
ifstreamifile;
ifile.open("C:
\\ProgramFiles\\data.txt",ios_base:
:
in);
while(!
ifile.eof())
{
ifile.getline(user1,25,'\n');
ifile.getline(password1,25,'\n');
if(strcmp(user1,user)==0&&strcmp(password1,password1)==0)
{
cout<<"\t\t\t登陆成功";
PD=1;
ifile.close();
system("cls");
cout<<"欢迎用户"<return;
}
}
cout<<"\t\t\t该用户没有注册或密码错误.\n";
PD=0;
ifile.close();
Sleep(2000);
system("cls");
}
voidxuanze()//选择函数
{
inta;
cin>>a;
switch(a)
{
case1:
zhuce();
break;
case2:
denglu();
break;
case3:
exit(0);//退出
default:
PD=0;
cout<<"序号错误";
Sleep(500);
}
}
intmain()//主函数
{
for(PD=1;PD;)
{
jm();
xuanze();
Zjm();
}
system("cls");
SetPos(25,2);
cout<<"感使用本软件!
";
return0;
}
4测试数据与实验结果(可以抓图粘贴)
测试:
(1)语句覆盖
路径1:
1-2-3-5-7-9
路径2:
1-2-4-6-8
(2)判定覆盖
路径1:
1-2-3-5-7-9
路径2:
1-2-3-5-2
路径3:
1-2-4-6-2
路径4:
1-2-4-6-8
(3)条件覆盖
路径1:
1-2-3-5-7-9
路径2:
1-2-4-6-8
路径3:
1--2-3-5-2-4-6-8
(4)条件组合覆盖
路径1:
1-2-3-5-7-9
路径2:
1-2-4-6-8
路径3:
1-2-3-5-2
路径4:
1-2-3-5-7-10
路径5:
1-2-4-6-2
5结果分析与实验体会
通过实验,要逐步提高白盒测试与黑盒测试技术的实际应用能力。
统学习和理解结构化软件工程实现阶段的基本概念、原理、技术和方法。
掌握软件测试的基本技术和方法,特别是白盒测试与黑盒测试技术和方法;