首页 > 其他 > 详细

WordCount测试项目小结

时间:2018-03-20 23:34:51      阅读:225      评论:0      收藏:0      [点我收藏+]

一、本文对应项目GitHub地址

https://github.com/ReWr1te/WCProject

二、项目PSP表格

PSP2.1 PSP阶段 预估耗时(分钟) 实际耗时(分钟)
Planning 计划 5 10
· Estimate · 估计这个任务需要多少时间 5 10
Development 开发 355 600
· Analysis · 需求分析 (包括学习新技术) 50 100
· Design Spec · 生成设计文档 10 10
· Design Review · 设计复审 (和同事审核设计文档) 25 50
· Coding Standard · 代码规范 (为目前的开发制定合适的规范) 10 20
· Design · 具体设计 100 100
· Coding · 具体编码 100 200
· Code Review · 代码复审 10 20
· Test · 测试(自我测试,修改代码,提交修改) 50 100
Reporting 报告 40 40
· Test Report · 测试报告 25 25
· Size Measurement · 计算工作量 5 5
· Postmortem & Process Improvement Plan · 事后总结, 并提出过程改进计划 10 10
合计 400 650

三、简单解题思路

  1. 需求分析:仔细阅读给出需求并细化,重新陈述以及思考解决难度;
  2. 设计文档:基本设计思路整理;
  3. 制定代码规范:根据指定的语言(Java)指定相关规范;
  4. 具体设计:核心算法设计,6个功能主要分为6部分,同时注意衔接;
  5. 具体编码;
  6. 代码复审:经验排错;
  7. 测试:撰写测试用例并完善,同时修改代码以提高质量;
  8. 总结和撰写报告;

四、实现流程及代码说明

Java类代码分为主函数和几个功能函数,但是并非所有功能都在功能函数里面实现。具体核心代码及说明参见以下代码和注释(更加详细的解释等待补充):

// 计算字符数
public static int chars(String str) {
char[] charArray = str.toCharArray();
int c_num = 0;
for (int i = 0; i < charArray.length; i++)
{
c_num++;
}
return c_num;
}
// 计算单词数
public static int words(String str) {
char[] charArray = str.toCharArray();
int w_num = 0;
for (int i = 0; i < charArray.length; i++)
{
if (charArray[i] == ‘ ‘ || charArray[i] == ‘,‘ || charArray[i] == ‘\n‘)
{
w_num++;
if (charArray[i] == ‘ ‘ && charArray[i - 1] == ‘,‘)
w_num--;
if (charArray[i] == ‘\n‘ &&
(charArray[i - 1] == ‘\n‘ ||
charArray[i - 1] == ‘{‘ || charArray[i - 1] == ‘}‘))
w_num--;
}
}
return w_num;
}
// stopList扣词
for (int i = 0; i < args.length; i++)
{
System.out.println(args[i]);
if (args[i].equals(str_e))
{
if (exclude == -1)
{
System.out.println("\n不能单独使用-e参数!\n");
out = false;
}
else
{
String[] strArray = str_read.split(" ");
String tempStr = e_sb.toString();
String[] e_str = tempStr.split(" ");
for (int j = 0; j < strArray.length; j++)
{
for (int k = 0; k < e_str.length; k++)
{
System.out.println(strArray[j] + e_str[k]);
if (strArray[j].indexOf(e_str[k]) != -1)
w_num--;
}
}
}
}
}
// 输出(若没有指定文件名则输出到result.txt,若没有文件则创建文件)
if (out == true)
{
File file = new File(filename);
if (!file.exists())
file.createNewFile();
FileWriter fileWriter = new FileWriter(file.getName(), true);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
bufferedWriter.write(str_output);
bufferedWriter.close();
}

五、测试设计

按照白盒测试设计方法,尽量覆盖所有功能:

(功能衔接处会有高风险,多设计两个测试用例)

  1. wc.exe -c -w -l test1.cpp
  2. wc.exe -c -w -l test2.c
  3. wc.exe -c -w -l -a test1.cpp
  4. wc.exe -c -w -l -a test2.c -e stopList.txt
  5. wc.exe -c -w -l -a test2.c -o outputFile.txt
  6. wc.exe -c -w -l -a test2.c -e stopList.txt -o outputFile.txt
  7. wc.exe -s *.cpp
  8. wc.exe -s *.c
  9. wc.exe -c -w -l -a -s *.cpp -e stopList.txt -o outputFile.txt
  10. wc.exe -c -w -l -a test1.cpp test2.c -e stopList.txt -o outputFile.txt

六、参考文献

本次项目无参考文献。

WordCount测试项目小结

原文:https://www.cnblogs.com/ShiyuanTian/p/8613462.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!