0《软件测试技术》实验报告河北工业大学计算机科学与软件学院2017年9月1软件说明电话号码问题某城市电话号码由三部分组成。它们的名称和内容分别是:地区码:空白或三位数字;前缀:非'0'或'1'的三位数字;后缀:4位数字。流程图源代码importjava.awt.*;importjava.awt.event.*;publicclassPhoneNumberextendsFrameimplementsActionListener{/****/privatestaticfinallongserialVersionUID=1L;2privatefinalString[]st={Name,Local,Prefix,Suffix};staticintc_person=0;TextFieldt_name,t_local,t_prefix,t_suffix;RecordDialogd_record;MessageDialogd_message;persona[]=newperson[100];publicPhoneNumber(){super(电话号码);this.setSize(250,250);this.setLocation(300,240);Panelpanel1=newPanel(newGridLayout(4,1));for(inti=0;ist.length;i++)panel1.add(newLabel(st[i],0));Panelpanel2=newPanel(newGridLayout(4,1));t_name=newTextField(,20);t_local=newTextField();t_prefix=newTextField();t_suffix=newTextField();panel2.add(t_name);panel2.add(t_local);panel2.add(t_prefix);panel2.add(t_suffix);Panelpanel3=newPanel(newFlowLayout());Buttonb_save=newButton(Save);Buttonb_record=newButton(Record);panel3.add(b_save);panel3.add(b_record);this.setLayout(newBorderLayout());this.add(West,panel1);this.add(East,panel2);this.add(South,panel3);addWindowListener(newWindowCloser());b_save.addActionListener(this);b_record.addActionListener(this);d_record=newRecordDialog(this);d_message=newMessageDialog(this);this.setVisible(true);3}privateclassRecordDialogextendsDialog{privatestaticfinallongserialVersionUID=1L;Frameframe;//对话框所依赖的框架窗口TextAreat_show;RecordDialog(Frameframe){super(frame,记录,true);this.frame=frame;this.setSize(300,80);t_show=newTextArea(20,20);this.add(t_show);this.addWindowListener(newWindowCloser());}publicvoidshow(Strings){t_show.setText(s);this.setLocation(frame.getX()+100,frame.getY()+100);this.setVisible(true);}}privateclassMessageDialogextendsDialog{/****/privatestaticfinallongserialVersionUID=1L;Frameframe;//对话框所依赖的框架窗口Labellabel;//对话框中显示信息MessageDialog(Frameframe){super(frame,消息,true);this.frame=frame;this.setSize(300,80);label=newLabel(,Label.CENTER);this.add(label);this.addWindowListener(newWindowCloser());}publicvoidshow(Stringstring){label.setText(string);this.setLocation(frame.getX()+100,frame.getY()+100);this.setVisible(true);}4}privateclassWindowCloserextendsWindowAdapter{publicvoidwindowClosing(WindowEventwe){Windowlabel=we.getWindow();label.setVisible(false);}}privateclassperson{Stringname,local,prefix,suffix;person(Stringname,Stringlocal,Stringprefix,Stringsuffix){this.name=name;this.local=local;this.prefix=prefix;this.suffix=suffix;}publicStringgetname(){returnname;}publicStringgetlocal(){returnlocal;}publicStringgetprefix(){returnprefix;}publicStringgetsuffix(){returnsuffix;}publicStringtoString(){returnthis.getname()+\t+this.getlocal()+\t+this.getprefix()+\t+this.getsuffix()+\n;}}publicbooleancheck(Stringlocal,Stringprefix,Stringsuffix){if((local.equals()||(local.length()==3&&local.matches([0-9]+)))&&(prefix.length()==3&&prefix.matches([2-9]+))&&(suffix.length()==4&&suffix.matches([0-9]+)))returntrue;returnfalse;}5publicvoidactionPerformed(ActionEvente){Stringlabel=e.getActionCommand();if(label==Save){Stringname=t_name.getText();Stringlocal=t_local.getText();Stringsuffix=t_suffix.getText();Stringprefix=t_prefix.getText();if(check(local,prefix,suffix)){a[c_person]=newperson(name,local,prefix,suffix);c_person++;}else{Stringmessage=;if(!local.equals()&&(local.length()!=3||!local.matches([0-9]+)))message+=localiserror,;if(prefix.length()!=3||!prefix.matches([2-9]+))message+=prefixiserror,;if((suffix.length()!=4||!suffix.matches([0-9]+)))message+=suffixiserror;message+=pleaseinputagain.;d_message.show(message);}t_name.setText();t_local.setText();t_prefix.setText();t_suffix.setText();}if(label==Record){d_record.show(this.toshow());}}publicStringtoshow(){Strings=name\tlocal\tprefix\tsuffix\n;for(inti=0;ic_person;i++)s+=a[i].toString();returns;}publicstaticvoidmain(Stringarg[]){newPhoneNumber();6}}界面7使用说明:name姓名接受:任意个字符有效:任意个字符local地区号接受:任意个字符有效:三个数字(0-9)不填,默认为空,可改进为默认值(当前地区)Prefix前缀接受:任意个字符有效:非'0'或'1'的三位数字Suffix后缀接受:任意个字符有效:4位数字(0-9)Save保存保存当前记录,清空文本框内容Record记录读取之前的记录8白盒测试实践判定—条件覆盖地区码空白取真为T1取假为F1三位取真为T2取假为F2数字0-9取真为T3取假为F3前缀三位取真为T4取假为F4数字2-9取真为T5取假为F5后缀四位取真为T6取假为F6数字0-9取真为T7取假为F7测试用例编号测试用例取值条件具体取值判定条件18791234F2F3-3数字-4数字T23335556666F13数字-3数字-4数字T333A5556666F3含字母-3数字-4数字F4335556666F22数字-3数字-4数字F53330006666F53数字-000-4数字F6333556666F43数字-2数字-4数字F7333555A666F73数字-3数字-含字母F833355566F63数字-3数字-2数字F测试报告用例ID地区码前缀后缀预期输出实际输出测试结果1空白8791234合法合法OK923335556666合法合法OK333a5556666不正确合法OK4335556666不正确合法OK5333556666不正确合法OK633355a6666不正确合法OK7333555a666不正确合法OK8333555566不正确合法OK10黑盒测试实践实验内容针对实验一所设计并实现的程序,制定功能测试测试计划,并利用所学黑盒测试的基本理论,设计测试用例,并在所开发的软件中进行测试。等价类划分:电话号码等价类有效等价类编号无效等价类编号空白1有非数字字符的三位数5地区码三位数字2少于三位数字6多余三位数字7有非数字字符的三位数8小于三位数9前缀200到999之间的数3大于三位数10含0的三位数11含1的三位数12有非数字字符的四位13后缀四位数字4少于四位数字14多余四位的数字15测试报告:用例ID地区码前缀后缀预期输出实际输出测试结果1空白8791234合法合法OK1123335556666合法合法OK333a5556666不正确合法OK4335556666不正确合法OK533335556666不正确合法OK633355a6666不正确合法OK7333556666不正确合法OK833355556666不正确合法OK9333556666不正确合法OK103331556666不正确合法OK11333555a666不正确合法OK12333555666不正确合法OK133335556666不正确合法OK12自动化单元测试实践实验内容针对实验二所设计并实现的程序