软件测试第二周个人作业--wordcount
1、Github项目地址:https://github.com/SSS-SY/wordcount
2、PSP2.1表格
|
PSP2.1 |
PSP阶段 |
预估耗时 (分钟) |
实际耗时 (分钟) |
|
Planning |
计划 |
20 |
15 |
|
· Estimate |
· 估计这个任务需要多少时间 |
30 |
15 |
|
Development |
开发 |
360 |
605 |
|
· Analysis |
· 需求分析 (包括学习新技术) |
60 |
80 |
|
· Design Spec |
· 生成设计文档 |
0 |
5 |
|
· Design Review |
· 设计复审 (和同事审核设计文档) |
0 |
0 |
|
· Coding Standard |
· 代码规范 (为目前的开发制定合适的规范) |
10 |
10 |
|
· Design |
· 具体设计 |
20 |
30 |
|
· Coding |
· 具体编码 |
180 |
360 |
|
· Code Review |
· 代码复审 |
40 |
60 |
|
· Test |
· 测试(自我测试,修改代码,提交修改) |
60 |
100 |
|
Reporting |
报告 |
60 |
85 |
|
· Test Report |
· 测试报告 |
40 |
60 |
|
· Size Measurement |
· 计算工作量 |
10 |
5 |
|
· Postmortem & Process Improvement Plan |
· 事后总结, 并提出过程改进计划 |
10 |
20 |
|
|
合计 |
440 |
705 |
3、解题思路:
a.对于参数功能选择设置HashMap存储-o -e -i文件路径,在输出文件时根据HashMap是否包含c、w、l、a判定输处内容
b.基本功能比较简单,只需读取文件内容后分别按行、按单词、按字符循环统计总数即可
c.对输出文件只需判断是否有选择输出文件然后修改output路径即可
d.对于-e StopLists只需读取文件内容以后创建Hash表然后统计字数时先判断是否在Hash表中即可
e.对于-a功能在统计字符数时使用trim()函数判断blank,使用contains()判断comments,其余情况即可视为code:
1.对于空白行只要trim()后该行总长度不超过1即为空白行***
2.对于代码行:不包含//注释符即为代码行***
3.除去以上两种情况以后包含//即为注释行***
f.对于-s功能递归处理输入文件列表然后在输出时循环调用输出功能结果功能即可
4.程序设计实现过程
a.查阅资料实现读取以及文件输出
b.设计HashMap实现参数解析
c.实现基本功能:
1.countLine:按行读取文件内容时统计行数
2.wordCount:按字读取文件内容后使用split(),标识为空格和‘,’
3.charCount:按行读取文件内容后累加每行length
d.实现-e功能:设置Hash表后在统计字数时预先判定是否在hash表中
e.实现-a功能:根据解题思路计算代码、空白以及注释行数
f.实现-s功能:递归实现 searchFiles
5.代码说明
//计算单词数
private static int wc(String contents,Set<String> stopLists)
//计算行数
private static int[] cl(String[] contents)
//计算字符数
private static int cc(String[] contents)
//stop words:
private static Set<String> stopWords(String stopfile)
//按行获取文件内容
private static ArrayList<String> getLines(String path)
//按字获取文件内容
private static String[] getWords(String path)
//输出结果
private static void ptintResultToFile(String file,Args args,PrintWriter output)
//递归寻找文件
private static String[] findFiles(String path,boolean s)
//参数设置
private static HashMap<Character, String> parseArgs(String[] args)
6.测试设计过程
a.先分别测试各个功能然后综合测试所有功能确保覆盖所有语句
b.具体测试用例放在test文件夹中
c.测试结果放在result文件夹中
测试用例:
1. wc.exe -c test1.c
2. wc.exe -c -o result1.text test1.c
3. wc.exe -w test1.c -o result2.text
4. wc.exe -l test1.c -o result3.text
5. wc.exe -a test1.c -o result4.text
6. wc.exe -w -e stopLists.c test1.c -o result5.text
7. wc.exe -l -w -a -c test1.c -o result6.text
8. wc.exe -c -s ./test/ -o result7.text
9. wc.exe -l -a -w -c -s ./test/ -o result8.text
10. wc.exe -l -a -c -e stopLists.c test2.c -o result9.text
7.参考文献链接
a.手把手教你如何把jar文件,打包成jar文件以及转换为exe可执行文件:http://blog.csdn.net/sunkun2013/article/details/13167099
b.作业内容:http://www.cnblogs.com/ningjing-zhiyuan/p/8563562.html
c.java读取文件内容方法:https://zhidao.baidu.com/question/620468183851139852.html
d.java输出内容至文件:http://blog.csdn.net/liuweiyuxiang/article/details/69487326
e.-s -e功能的实现方法,参考明煦智同学github:https://github.com/mxz96102/word_count

浙公网安备 33010602011771号