《软件测试技术》实验报告河北工业大学计算机科学与软件学院2017年9月软件说明电话号码问题某城市电话号码由三部分组成。
它们的名称和内容分别是:地区码:空白或三位数字;前缀:非'0'或'1'的三位数字;后缀:4位数字。
流程图源代码import java.awt.*;import java.awt.event.*;public class PhoneNumber extends Frame implements ActionListener{/****/private static final long serialVersionUID = 1L;private final String[] st = {"Name","Local","Prefix","Suffix"}; static int c_person=0;TextField t_name,t_local,t_prefix,t_suffix;RecordDialog d_record;MessageDialog d_message;person a[]=new person[100];public PhoneNumber(){super("电话号码");this.setSize(250,250);this.setLocation(300,240);Panel panel1 = new Panel(new GridLayout(4, 1));for (int i = 0; i < st.length; i++)panel1.add(new Label(st[i],0));Panel panel2 = new Panel(new GridLayout(4, 1));t_name =new TextField("",20);t_local =new TextField("");t_prefix=new TextField("");t_suffix=new TextField("");panel2.add(t_name);panel2.add(t_local);panel2.add(t_prefix);panel2.add(t_suffix);Panel panel3 = new Panel(new FlowLayout());Button b_save = new Button("Save");Button b_record= new Button("Record");panel3.add(b_save);panel3.add(b_record);this.setLayout(new BorderLayout());this.add("West", panel1);this.add("East", panel2);this.add("South", panel3);addWindowListener(new WindowCloser());b_save.addActionListener(this);b_record.addActionListener(this);d_record=new RecordDialog(this);d_message=new MessageDialog(this);this.setVisible(true);}private class RecordDialog extends Dialog{private static final long serialVersionUID = 1L;Frame frame; //对话框所依赖的框架窗口TextArea t_show;RecordDialog(Frame frame){super(frame,"记录",true);this.frame=frame;this.setSize(300, 80);t_show=new TextArea(20,20);this.add(t_show);this.addWindowListener(new WindowCloser());}public void show(String s) {t_show.setText(s);this.setLocation(frame.getX()+100, frame.getY()+100);this.setVisible(true);}}private class MessageDialog extends Dialog{/****/private static final long serialVersionUID = 1L;Frame frame; //对话框所依赖的框架窗口Label label; //对话框中显示信息MessageDialog(Frame frame){super(frame,"消息",true);this.frame=frame;this.setSize(300, 80);label=new Label("",Label.CENTER);this.add(label);this.addWindowListener(new WindowCloser());}public void show(String string){label.setText(string);this.setLocation(frame.getX()+100, frame.getY()+100);this.setVisible(true);}}private class WindowCloser extends WindowAdapter{public void windowClosing(WindowEvent we){Window label = we.getWindow();label.setVisible(false);}}private class person{String name,local,prefix,suffix;person(String name,String local,String prefix,String suffix){=name;this.local=local;this.prefix=prefix;this.suffix=suffix;}public String getname(){return name;}public String getlocal(){return local;}public String getprefix(){return prefix;}public String getsuffix(){return suffix;}public String toString(){returnthis.getname()+"\t"+this.getlocal()+"\t"+this.getprefix()+"\t"+this.getsuffix()+"\n";}}public boolean check(String local,String prefix,String suffix){if((local.equals("")||(local.length()==3&&local.matches("[0-9]+")))&&(prefix.length()==3&&prefix.matches("[2-9]+"))&&(suffix.length()==4&&suffix.matches("[0-9]+")))return true;return false;}public void actionPerformed(ActionEvent e) {String label = e.getActionCommand();if(label=="Save"){String name=t_name.getText();String local=t_local.getText();String suffix=t_suffix.getText();String prefix=t_prefix.getText();if(check(local,prefix,suffix)){a[c_person]=new person(name,local,prefix,suffix);c_person++;}else{String message="";if(!local.equals("")&&(local.length()!=3||!local.matches("[0-9]+"))) message+="local is error,";if(prefix.length()!=3||!prefix.matches("[2-9]+"))message+="prefix is error,";if((suffix.length()!=4||!suffix.matches("[0-9]+")))message+="suffix is error";message+="please input again.";d_message.show(message);}t_name.setText("");t_local.setText("");t_prefix.setText("");t_suffix.setText("");}if(label=="Record"){d_record.show(this.toshow());}}public String toshow(){String s="name\tlocal\tprefix\tsuffix\n";for(int i=0;i<c_person;i++)s+=a[i].toString();return s;}public static void main(String arg[]){new PhoneNumber();} }界面使用说明:name 姓名接受:任意个字符有效:任意个字符local 地区号接受:任意个字符有效:三个数字(0-9)不填,默认为空,可改进为默认值(当前地区)Prefix 前缀接受:任意个字符有效:非'0'或'1'的三位数字Suffix 后缀接受:任意个字符有效:4位数字(0-9)Save 保存保存当前记录,清空文本框内容Record 记录读取之前的记录白盒测试实践判定—条件覆盖地区码空白取真为T1取假为F1三位取真为T2取假为F2数字0-9 取真为T3取假为F3前缀三位取真为T4取假为F4数字2-9 取真为T5取假为F5后缀四位取真为T6取假为F6数字0-9 取真为T7取假为F7测试用例编号测试用例取值条件具体取值判定条件1 8791234 F2 F3 -3数字-4数字T2 3335556666 F1 3数字-3数字-4数字T3 33A5556666 F3 含字母-3数字-4数字 F4 335556666 F2 2数字-3数字-4数字 F5 3330006666 F5 3数字-000-4数字 F6 333556666 F4 3数字-2数字-4数字 F7 333555A666 F7 3数字-3数字-含字母 F8 33355566 F6 3数字-3数字-2数字 F测试报告用例ID 地区码前缀后缀预期输出实际输出测试结果1 空白879 1234 合法合法OK2 333 555 6666 合法合法OK3 33a 555 6666 不正确合法OK4 33 555 6666 不正确合法OK5 333 55 6666 不正确合法OK6 333 55a 6666 不正确合法OK7 333 555 a666 不正确合法OK8 333 5555 66 不正确合法OK黑盒测试实践实验内容针对实验一所设计并实现的程序,制定功能测试测试计划,并利用所学黑盒测试的基本理论,设计测试用例,并在所开发的软件中进行测试。