第四周小组作业WordCount的优化

输出模块测试与分析
本文详细介绍了输出模块的开发流程,包括需求分析、设计、编码及测试等阶段,并提供了具体的测试用例和单元测试结果。

一、GitHub地址为

 https://github.com/decadeheart/WcPlus

二、PSP表格

 

PSP2.1

PSP阶段

预估耗时

(分钟)

实际耗时

(分钟)

Planning

计划

6060

· Estimate

预估

6060

Development

开发

  

· Analysis

· 需求分析 (包括学习新技术)

6050

· Design Spec

· 生成设计文档

100100

· Design Review

· 设计复审 (和同事审核设计文档)

2030

· Coding Standard

· 代码规范 (为目前的开发制定合适的规范)

3030

· Design

· 具体设计

3040

· Coding

· 具体编码

150200

· Code Review

· 代码复审

3020

· Test

· 测试(自我测试,修改代码,提交修改)

4060

Reporting

报告

3020

· Test Report

· 测试报告

150150

· Size Measurement

· 计算工作量

3020

· Postmortem & Process Improvement Plan

· 事后总结, 并提出过程改进计划

2010
 

合计

750

82

 

三、模块编写和测试

这次我负责的是输出模块,主要是将排好序的数组输出到指定文件,并在输出之前判定数组中的个数是否达到要求,如果不足100个,会在输出的指定文件

的开头输出文件中单词数量。以下对该模块的设计和测试进行说明。

模块设计

首先在事先设计好的类中定义好相关属性,并通过if和for语句判定和进行相应的输出 通过VS测试脚本

ofstream output("result.txt");
        if (output.is_open())
        {
        if (result.size() < 100)
                {
                for (auto p = result.begin(); p != result.end()-1; ++p)
                        {
                    output << p->first << " " << p->second << endl;
                        }
output << result[result.size() - 1].first << " " << result[result.size() - 1].second;
                }
        else
                {
        for (auto p = result.begin(); p != result.begin() + 99; ++p)
            {
            output << p->first << " " << p->second << endl;
                        }
        output << result[99].first << " " << result[99].second;
                }
        }
        else
        { 
cout<<"打不开文件";

        }
        output.close();

 

四、测试用例设计

这部分功能可以分成四个部分:正常输出元素为100的数组,大于100个元素的数组,小于100个的数组,打不开指定文件并返回“打不开文件”,因此我们针对这几个不同的功能部分来分别设计测试用例。

  测试用例显示如下:

Test Case ID 测试用例编号Test Item 测试项(即功能模块或函数)Test Case Title 测试用例标题Test Criticality重要级别Pre-condition 预置条件Input 输入Procedure 操作步骤Output 预期结果Result
实际结果
Status
是否通过
Remark 备注(在此描述使用的测试方法)
FileNotOpen1output.is_open()FunctionTestSetHigh文件不能打开a 1,b 1,d 2,e 2 打不开文件打不开文件ok 
FileNotOpen2output.is_open()High文件不能打开a 2,b 2,d 2,e 2 打不开文件打不开文件ok 
FileNotOpen3output.is_open()High文件不能打开a 2,b 2,d 2,e 3 打不开文件打不开文件ok 
FileNotOpen4output.is_open()High文件不能打开a 1,b 1,d 2,e 4 打不开文件打不开文件ok 
FileNotOpen5output.is_open()High文件不能打开a 2,b 2,d 2,e 5 打不开文件打不开文件ok 
OutPutNormal1ofstream output("result.txt")High文件可以用记事本打开boy 4,q 5,c 8通过不断更改所得到的单词个数,以及单词的词频数,来进行检测boy 4,q 5,c 8boy 4,q 5,c 8ok 
OutPutNormal2ofstream output("result.txt")High文件可以用记事本打开d 3,f 5,g 4d 3,f 5,g 4d 3,f 5,g 4ok 
OutPutNormal3ofstream output("result.txt")High文件可以用记事本打开a 1,b 1,d 2,e 2a 1,b 1,d 2,e 2a 1,b 1,d 2,e 2ok 
OutPutNormal4ofstream output("result.txt")High文件可以用记事本打开a 1,b 1,d 2,e 4a 1,b 1,d 2,e 4a 1,b 1,d 2,e 4ok 
OutPutNormal5ofstream output("result.txt")High文件可以用记事本打开a 2,b 2,d 2,e 2a 2,b 2,d 2,e 2a 2,b 2,d 2,e 2ok 
OutPutAbnormal1ofstream output("result.txt")High文件可以用记事本打开a 2,b 2,d 2,e 3a 2,b 2,d 2,e 3a 2,b 2,d 2,e 3ok 
OutPutAbnormal2ofstream output("result.txt")High文件可以用记事本打开a 2,b 2,d 2,e 5a 2,b 2,d 2,e 5a 2,b 2,d 2,e 5ok 
OutPutAbnormal3ofstream output("result.txt")High文件可以用记事本打开I 4, n 9,c 8,m 5I 4, n 9,c 8,m 5I 4, n 9,c 8,m 5ok 
OutPutAbnormal4ofstream output("result.txt")High文件可以用记事本打开high 1, building 4, world 10high 1, building 4, world 10high 1, building 4, world 10ok 
OutPutAbnormal5ofstream output("result.txt")High文件可以用记事本打开high 1, building 4, world 11high 1, building 4, world 11high 1, building 4, world 11ok 
OutPutAbnormal6ofstream output("result.txt")High文件可以用记事本打开high 1, building 4, world 12high 1, building 4, world 12high 1, building 4, world 12ok 
OutPutAbnormal7ofstream output("result.txt")High文件可以用记事本打开high 1, building 4, world 13high 1, building 4, world 13high 1, building 4, world 13ok 
OutPutAbnormal8ofstream output("result.txt")High文件可以用记事本打开high 1, building 4, world 14high 1, building 4, world 14high 1, building 4, world 14ok 
OutPutAbnormal9ofstream output("result.txt")High文件可以用记事本打开high 1, building 4, world 15high 1, building 4, world 15high 1, building 4, world 15ok 
OutPutAbnormal10ofstream output("result.txt")High文件可以用记事本打开high 1, building 4, world 16high 1, building 4, world 16high 1, building 4, world 16ok 

五、单元测试结果

 通过使用VS脚本进行单元测试,测试的文件和结果可以看GitHub,结果是正确的

六、静态代码扫描

 

 

七、小组贡献

本次任务我负责输出模块的操作,小组里的其他组员没有懈怠,都付出了自己的努力,我贡献为0.20

 

八、组内代码分析

小组内的组员对于这次的程序很关心其代码的规范,所以在这个方面大家做的都很好

 

九、 小结

在此次小组任务中在进行测试用例的时候因为要求平均每人二十个,所以跟组员讨论了一下怎么去把测试结果在这二十个用例中很好的表现出来,对软件测试这门课的有了更深的理解,但还远远不够,要花更多时间去学习。

 

 

 

 

转载于:https://www.cnblogs.com/liutzh1105/p/8745419.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值