WordCount测试项目小结
一、本文对应项目GitHub地址
https://github.com/ReWr1te/WCProject
请参照最新版本(WCProject4.0)
二、项目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 |
三、简单解题思路
- 需求分析:仔细阅读给出需求并细化,重新陈述以及思考解决难度;
- 设计文档:基本设计思路整理;
- 制定代码规范:根据指定的语言(Java)指定相关规范;
- 具体设计:核心算法设计,6个功能主要分为6部分,同时注意衔接;
- 具体编码;
- 代码复审:经验排错;
- 测试:撰写测试用例并完善,同时修改代码以提高质量;
- 总结和撰写报告;
四、程序设计实现流程
本项目Java代码只有一个wc类,4个函数:
- 主函数:包含核心算法流程和输出类测试用例;
- getFile()函数:递归获取当前文件夹内所有文件(排除文件夹);
- chars()函数:计算字符数;
- words()函数:计算单词数;
主函数调用其余函数完成功能,部分功能在主函数内单独实现。
五、代码说明
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;
}
// 得到当前目录内所有文件(本程序中并没有使用这个方法遍历文件,但是这个方法证实可行)
public static void getFile(File file) {
File[] files = file.listFiles();
for (File a:files) {
if (!a.isDirectory())
arr_files.add(a.getAbsolutePath());
else
getFile(a);
}
}
// 参数判断
for (int i = 0; i < args.length; i++)
{
if (args[i].indexOf(".") != -1)
{
if (args[i - 1].indexOf(".") != -1)
{
arr_inputs.add(args[i]);
allfile = i;
file_count++;
}
else if (args[i].indexOf("stopList.txt") != -1)
exclude = i;
else if (input == -1)
{
arr_inputs.add(args[i]);
input = i;
file_count++;
}
else
output = i;
}
if (file_count >= 2)
allfile = 1;
}
// 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--;
}
}
}
}
}
// 输出准备+测试用例
for (int i = 0; i < args.length; i++)
{
if (args[i].equals(str_c))
{
// System.out.println("\n字符数:" + c_num);
str_output = str_output + this_file + ","
+ "字符数:" + c_num + "\r\n";
}
if (args[i].equals(str_w))
{
// System.out.println("\n单词数:" + w_num);
str_output = str_output + this_file + ", "
+ "单词数:" + w_num + "\r\n";
}
if (args[i].equals(str_l))
{
// System.out.println("\n行数: " + line);
str_output = str_output + this_file + ","
+ "行数:" + line + "\r\n";
}
if (args[i].equals(str_o))
{
if (output == -1)
{
System.out.println("\n不能单独使用-o参数!\n");
out = false;
}
else
filename = args[output];
}
if (args[i].equals(str_a))
{
// System.out.println("\n代码行/空行/注释行:"
// + line_code + "/"
// + line_null + "/" + line_comment);
str_output = str_output + this_file + ","
+ "代码行/空行/注释行: " + line_code + "/"
+ line_null + "/" + line_comment + "\r\n";
}
}
// 输出(若没有指定文件名则输出到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();
}
改进之后能够在.exe文件形式下处理一般通配符:
// 得到当前目录内所有文件
public static void getFiles(File file) {
File[] files = file.listFiles();
for (File a:files) {
if (!a.isDirectory())
arr_files.add(a.getName());
else
getFiles(a);
}
}
//参数判断
for (int i = 0; i < args.length; i++) {
if (args[i].indexOf(".") != -1) {
if (args[i].indexOf("*.") != -1) {
type = args[i].replace("*", "");
allfile = i;
}
else if (args[i].indexOf("stopList.txt") != -1)
exclude = i;
else if (input == -1)
input = i;
else
output = i;
}
}
六、测试设计
本来的思路是按照白盒测试设计各个路径的测试用例,但是实际上因为程序比较简单,所以最后应该是黑盒测试的设计思路,尽量覆盖所有功能:
(功能衔接处会有高风险,多设计两个测试用例)
- wc.exe -c -w -l test1.cpp
同时测试-c -w -l三个基础的功能 - wc.exe -c -w -l test2.c
在用例1的基础上改变文件类型 - wc.exe -c -w -l -a test1.cpp
在用例1的基础上添加-a参数,测试输出行类型信息 - wc.exe -c -w -l -a test2.c -e stopList.txt
在用例3的基础上添加-e参数,测试停用词表 - wc.exe -c -w -l -a test2.c -o outputFile.txt
在用例3的基础上添加-o参数,测试指定输出文件的功能 - wc.exe -c -w -l -a test2.c -e stopList.txt -o outputFile.txt
在用例3的基础上添加-e和-o参数,同时测试停用词表和指定输出文件功能 - wc.exe -s *.cpp
测试-s参数,处理多个文件的功能 - wc.exe -s *.c
在用例8的基础上改变输入文件的类型 - wc.exe -c -w -l -a -s *.cpp -e stopList.txt -o outputFile.txt
结合测试用例6,7,同时处理基础功能,行类型信息,多文件,停用词表和指定输出文件名 - wc.exe -c -w -l -a test1.cpp test2.c -e stopList.txt -o outputFile.txt
在用例9的基础上改变多文件处理的类型
七、参考文献
本次项目无参考文献。
WordCount测试项目小结的更多相关文章
- .NET项目开发—浅谈面向接口编程、可测试性、单元测试、迭代重构(项目小结)
阅读目录: 1.开篇介绍 2.迭代测试.重构(强制性面向接口编程,要求代码具有可测试性) 2.1.面向接口编程的两个设计误区 2.1.1.接口的依赖倒置 2.1.2.接口对实体的抽象 2.2.迭代单元 ...
- [2017BUAA软工助教]个人项目小结
2017BUAA个人项目小结 一.作业链接 http://www.cnblogs.com/jiel/p/7545780.html 二.评分细则 0.注意事项 按时间完成并提交--正常评分 晚交一周以内 ...
- [2017BUAA软工助教]结对项目小结
2017BUAA结对项目小结 一.作业链接 http://www.cnblogs.com/jiel/p/7604111.html 二.评分细则 1.注意事项 按时间完成并提交--正常评分 晚交一周以内 ...
- 关于iOS10 Xcode8真机测试项目出现的问题 "code signing is required for product type 'xxxxx' in SDK 'iOS 10.0"..
昨天用真机测试项目出现这样的错误,在网上搜集了一些信息,所以将自己的经验分享出来帮助更多的人. 第一步: 检查你的1和2是否填写正确,如果你是运行别人的项目,BundleIdentifier要和你的X ...
- 编码的UI测试项目——Visual Studio 2013
今天实现了一次编码的UI测试项目,以下是我进行测试的过程: 1.新建测试项目 在visual studio中(我用的版本是2013 update2)点击文件->新建->项目,选择“编码的U ...
- Hadoop3.0 WordCount测试一直Accept 状态,Nodes of the cluster 页面node列表个数为0
起因是我运行wordcount测试一直卡主,不能执行,一直处于 Accept 状态,等待被执行,刚开始是各种配置yarn参数,以及host配置,后来发现还是不行 hadoop 集群安装完成后,在500 ...
- 记一次SSM项目小结(一)
记一次SSM项目小结(一) ssm框架 环境配置 服务器配置 解决方法 拦截器重定向到localhost nginx和tomcat中session失效 mybatis的xml文件不生效 数据库用户创 ...
- Hadoop基础-MapReduce入门篇之编写简单的Wordcount测试代码
Hadoop基础-MapReduce入门篇之编写简单的Wordcount测试代码 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本文主要是记录一写我在学习MapReduce时的一些 ...
- 02.基于IDEA+Spring+Maven搭建测试项目--详细过程
一.背景介绍 1.1公司相关技术 Git:是一款免费的开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目,方便多人集成开发 Maven:是基于项目对象模型(POM),可以通过一小段描述信息 ...
随机推荐
- es6编程建议和技巧点汇总
大括号 特点:大括号(单独的大括号或者if等后的大括号)内是一个单独的作用域 注意点:在块级作用域内声明的函数,类似var,会被提升到大括号外,应避免在块级作用域内声明函数.如果确实需要,写成函数表达 ...
- 关于模拟I2C的一些问题???
1.在调试BH1750时发现stm32f103rb单片机用模拟I2C通讯时引脚使用开漏模式能正常读出来数据,使用推挽模式则完全无法通讯,发送地址后从机没有应答? https://blog.csdn.n ...
- C++ 变长模板参数
转载自: http://www.cnblogs.com/liyiwen/archive/2013/04/13/3018608.html C++11 语言核心的改进中,最为关注的有 rvalue ref ...
- 论文笔记:Deep feature learning with relative distance comparison for person re-identification
这篇论文是要解决 person re-identification 的问题.所谓 person re-identification,指的是在不同的场景下识别同一个人(如下图所示).这里的难点是,由于不 ...
- jenkins备份与恢复【转】
jenkins这里我通过thinbackup插件进行对jenkins的配置备份与恢复 1丶安装thinbackup插件 2丶系统管理选择thinbackup插件 3丶创建备份目录 mkdir /bac ...
- 【转】Java中的static关键字解析
一.static关键字的用途 在<Java编程思想>P86页有这样一段话: “static方法就是没有this的方法.在static方法内部不能调用非静态方法,反过来是可以的.而且可以在没 ...
- 斜率优化dp 的简单入门
不想写什么详细的讲解了...而且也觉得自己很难写过某大佬(大米饼),于是建议把他的 blog 先看一遍,然后自己加了几道题目以及解析...顺便建议看看算法竞赛(蓝皮书)的 0x5A 斜率优化(P294 ...
- Bootstrap modal常用参数、方法和事件
Bootstrap modal(模态窗)常用参数.方法和事件: 参数: 名称 类型 默认值 描述 Backdrop Boolean或字符串“static” True True:有背景,点击modal外 ...
- docker容器与宿主主机之间拷贝文件
文章链接:https://blog.csdn.net/libertine1993/article/details/80651552 https://blog.csdn.net/u011596455/a ...
- jquery 查找子窗口
$("#订单信息").contents().find('div.datagrid-body').hide();$("#订单信息").contents().fin ...