第2周个人作业:WordCount
Github地址
https://github.com/ohayogirls/SoftwareTest
PSP表格
PSP2.1 |
PSP阶段 |
预估耗时 (分钟) |
实际耗时 (分钟) |
Planning |
计划 |
30 | 60 |
· Estimate |
· 估计这个任务需要多少时间 |
10 | 10 |
Development |
开发 |
600 | 600 |
· Analysis |
· 需求分析 (包括学习新技术) |
120 | 180 |
· Design Spec |
· 生成设计文档 |
30 | 60 |
· Design Review |
· 设计复审 (和同事审核设计文档) |
10 | 20 |
· Coding Standard |
· 代码规范 (为目前的开发制定合适的规范) |
30 | 40 |
· Design |
· 具体设计 |
120 | 180 |
· Coding |
· 具体编码 |
300 | 480 |
· Code Review |
· 代码复审 |
40 | 60 |
· Test |
· 测试(自我测试,修改代码,提交修改) |
200 | 300 |
Reporting |
报告 |
60 | 80 |
· Test Report |
· 测试报告 |
60 | 60 |
· Size Measurement |
· 计算工作量 |
30 | 30 |
· Postmortem & Process Improvement Plan |
· 事后总结, 并提出过程改进计划 |
30 | 40 |
合计 |
1670 | 2200 |
代码说明
/*
在没有-s命令的情况下执行-c命令
-w -l命令同理,-a命令将readFile函数改成countCode函数
*/
if((optnum=opt.indexOf("-s"))==-1){
//-c选项:返回文件 file.c 的字符数
if((optnum=opt.indexOf("-c"))!=-1){
int i = optNum.get(optnum);//获得选项在args中的位置
while(true){
if(fileName.contains(args[++i])){
break;
}
}
readFile(args[i],'c',outputPath);
}
/*
在有-s命令的情况下递归执行-c命令
其他命令同理
*/
for(String f:filelist){
if((optnum=opt.indexOf("-c"))!=-1){
readFile(f,'c',outputPath);
}
}
//没有-o命令默认输出到result.txt
if((optnum=opt.indexOf("-o"))==-1){
File output = new File(outputPath);
output.createNewFile();
FileWriter fw = new FileWriter(output);
fw.write("");
fw.close();
}
//-o命令
if((optnum=opt.indexOf("-o"))!=-1){
int i = optNum.get(optnum);//获得选项在args中的位置
while(true){
if(fileName.contains(args[++i])){
break;
}
}
outputPath=args[i];
File output = new File(outputPath);
output.createNewFile();
FileWriter fw = new FileWriter(output);
fw.write("");
fw.close();
测试设计过程
考虑在测试所有功能的基础上,覆盖程序的每一条可执行路径。
测试用例里要用到的文件放在和wc.exe一个目录下
- 测试单个基础功能选项是否正确输出在result.txt
- wc.exe -c file.c
- wc.exe -w file.c
- wc.exe -l file.c
- wc.exe -a file.c
- 测试绝对路径下是否正确
-wc.exe -c [测试环境下的绝对路径] - 测试多个选项能否共享一个参数
- wc.exe -c -w -l -a file.c
- 测试同时读取不同的文件
- wc.exe -c file1.c -w file2.c -l file3.c
- 测试指定输出文件
- wc.exe -c -w -l -a file.c -o output1.txt
- 测试递归处理目录下符合条件的文件
- wc.exe -c -w -l -a -s *.c -o output2.txt
- 测试停用词表
- wc.exe -w -file.c -e stoplist.txt
- 执行所有选项命令
- wc.exe -c -w -l -a -s *.c -o output3.txt -e stoplist.txt