一、GitHub地址
https://github.com/duwei1996/wcPro
二、PSP表格
PSP2.1 | PSP阶段 | 预估耗时 (分钟) | 实际耗时 (分钟) |
Planning | 计划 |
|
|
· Estimate | · 估计这个任务需要多少时间 | 10 | 10 |
Development | 开发 |
| |
· Analysis | · 需求分析 (包括学习新技术) | 20 | 20 |
· Design Spec | · 生成设计文档 | 10 | 10 |
· Design Review | · 设计复审 (和同事审核设计文档) | 10 | 10 |
· Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 10 | 10 |
· Design | · 具体设计 | 20 | 20 |
· Coding | · 具体编码 | 30 | 30 |
· Code Review | · 代码复审 | 10 | 10 |
· Test | · 测试(自我测试,修改代码,提交修改) | 30 | 30 |
Reporting | 报告 |
|
|
· Test Report | · 测试报告 | 10 | 10 |
· Size Measurement | · 计算工作量 | 10 | 10 |
· Postmortem & Process Improvement Plan | · 事后总结, 并提出过程改进计划 | 10 | 10 |
| 合计 | 180 | 180
|
三、接口实现
负责项目的输入功能以及对接口功能的测试
- Input 类简介
- 该类具有一个含一个String参数的构造器,用于接收命令行输入的字符串
- 其中的readToString()函数用于实现读取文件内容的功能
- 主要函数readToString()
- 实现逻辑:接收字符串,作为文件名;读取文件内容,并读入一个 byte [] 数组;处理常见的异常,如FileNotFoundException等
- 代码
import java.io.*; public class Input { private String filename; public Input(String filename){ this.filename=filename; } public String readToString(){ String encoding = "GBK"; File file = new File(filename); Long filelength = file.length(); byte[] filecontent = new byte[filelength.intValue()]; try { FileInputStream in = new FileInputStream(file); in.read(filecontent); in.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { return new String(filecontent, encoding); } catch (UnsupportedEncodingException e) { System.err.println("The OS does not support " + encoding); e.printStackTrace(); return null; } } }
- 测试
- 这里在GitHub中单独添加了一个inputTest文件夹,里面是经加工的 input.java 文件,以及生成的19+1个测试文件
- 代码
//随机生成字符串 public static String getRandomString(int length) { String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";//含有字符和数字的字符串 Random random = new Random();//随机类初始化 StringBuffer sb = new StringBuffer();//StringBuffer类生成,为了拼接字符串 for (int i = 0; i < length; ++i) { int number = random.nextInt(62);// [0,62) sb.append(str.charAt(number)); } return sb.toString(); } public static void main(String[] args) throws IOException{ ArrayList<String> fileNames = new ArrayList<>(); //创建文件,并读取字符串 for (int i = 0;i < 19;i++){ String fileName = new String("test" + (i+1) +".txt"); fileNames.add(fileName); File output = new File(fileName); output.createNewFile(); String content = getRandomString(10); PrintStream ps = new PrintStream(new FileOutputStream(output)); ps.println(content);// 往文件里写入字符串 } String noFile = new String("test20.txt"); fileNames.add(noFile); for (int i = 0; i< 20;i++){ String s = fileNames.get(i); Input input = new Input(s); System.out.println(s + "\r\n" + input.readToString()); } }
- 测试逻辑:
- getRandomString() 函数用于随机生成字符串,之后将字符串赋给文件
- main() 函数里创建20个文件,然后将随机生成的字符串读到文件中,调用 Input 类中的 readToString() 函数进行测试
- 测试文件及结果
- 测试文件见GitHub中的inputTest文件夹
- 测试结果
四、测试评价
测试模块较为简单,采用了黑盒测试,测试用例相较于其他模块比较单一,对具有一定内容的文件进行了测试,并且对文件不存在的情况进行了测试,有一定参考价值。
五、小组贡献分
0.33
六、参考链接
http://www.cnblogs.com/ningjing-zhiyuan/p/8654132.html