软件质量与测试第4周小组作业:WordCount优化

软件质量与测试第4周小组作业:WordCount优化

一、GitHub地址

https://github.com/fusidic/WC

二、PSP表格

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

三.模块接口设计

处于任务分配的考量,我们小组将整个任务分成了输入控制 内容读取 分析核心 输出控制 几个功能模块,同时在组长17002的建议下,我们采用了Kotlin来进行模块的编写,因为Kotlin简洁,同时兼容Java,可以用Junit进行单元测试。

我负责的模块,主要完成文件及参数读取的功能,入口为ArgChecker类中的check函数

fun check(pindex: Int, pc: Int, msg: String): Boolean {
    if (pindex <= -1) return false
    if (pindex + 1 == pc) {
        throw IllegalArgumentException(msg)
    }

    return true
}

checkOutputArg()检验输入参数的合法性

fun checkOutputArg(oindex: Int, args: Array<String>): Boolean {
    val ofname = args[oindex + 1]
    if (Options.values().map { it.value }.contains(ofname)) {
        throw IllegalArgumentException("invalid output file name")
    }
    return true
}

对于不同参数功能的调用则放在了主函数中

for (value in Options.values()) {
    val index = args.indexOf(value.value)
    if (index == -1) {
        continue
    }
    when (value) {
        Options.C -> {
        checker.check(index, pc, "-c error")
        cc = CharCounter().count(ifile)
        }
        Options.W -> {
            checker.check(index, pc, "-w error")
            wc = WordCounter().count(ifile)
        }
        Options.L -> {
            checker.check(index, pc, "-l error")
            lc = LineCounter().count(ifile)
        }
        else -> {

        }
    }
}

文件的字数统计则简单的采用了Kotlin中的库函数file.readText().length

四、设计测试用例与测试

对于CharCounter(),使用了Junit对其进行了单元测试,测试的文本是某网页上的若干段文字(位于类CounterTest中),通过文本软件获得了测试文本的字符数,然后编辑其测试程序

package test.com.dashmrl.wc.counter

import com.dashmrl.wc.counter.CharCounter
import org.junit.Test
import java.io.File
import kotlin.test.assertEquals

/**
 * Author    fusidic
 * Time      10:25
 * Date      2018/4/8
 * Email     [email protected]
 */
class CharCounterTest : CounterTest() {
    private val results = arrayOf(
            282,
            83,
            53,
            57,
            62,
            127,
            87,
            157,
            73,
            38,
            62,
            46,
            162,
            100,
            69,
            65,
            47,
            35,
            9,
            139
    )

    @Test
    fun count() {
        inputs.forEach {
            val c = CharCounter().count(createIntputFile(it, "input.txt"))
            assertEquals(results[inputs.indexOf(it)],c,"not equals,exit!!")
        }
    }
}

测试得到所有结果都与标准相符。

而对于参数输入的测试,因为参数的判断写在主函数中,在其他功能模块都完成了的情况下,ArgChecker的测试采用了黑盒测试的方法,通过bat脚本对其进行了黑盒测试。

wcPro.exe
wcPro.exe -c
wcPro.exe -w
wcPro.exe -l
wcPro.exe input.txt
wcPro.exe -c input.txt
wcPro.exe -w input.txt
wcPro.exe -l -o result.txt input.txt
wcPro.exe -c -w -l -o result.txt input.txt

以下列举某次测试的结果,对非法输入给出了警告:

PS C:\Users\Arith\Desktop> .\wcPro.exe -w
java.lang.IllegalArgumentException: no enough args!!
        at com.dashmrl.wc.WCKt.main(WC.kt:19)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:81)
        at com.exe4j.runtime.WinLauncher.main(WinLauncher.java:94)

五、小组贡献分

0.27

六、参考链接

http://www.cnblogs.com/ningjing-zhiyuan/p/8654132.html

邹欣 代码规范与代码复审

原文地址:https://www.cnblogs.com/fisidic/p/8747029.html

时间: 2024-08-25 19:48:34

软件质量与测试第4周小组作业:WordCount优化的相关文章

软件质量与测试第4周小组作业:WordCountPro

1.Git地址: https://github.com/Hare-Lucius/WordCountPro 2.PSP表格 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划 20 10 · Estimate · 估计这个任务需要多少时间 20 10 Development 开发 260 305 · Analysis · 需求分析 (包括学习新技术) 20 20 · Design Spec · 生成设计文档 20 20 · Design Review · 设计

第4周小组作业 WordCount优化

github地址:https://github.com/husterC/WordCountGroupwork PSP表格 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划  20  20 · Estimate · 估计这个任务需要多少时间  15  10 Development 开发  60  40 · Analysis · 需求分析 (包括学习新技术)  60  90 · Design Spec · 生成设计文档  -  - · Design Revie

软件质量与测试 第4周个人作业

一.项目地址 https://github.com/changjiang666/WcPro 二.PSP 三.设计思路 我负责main函数的编写和print输出模块的编写. 1.main函数 int main(/*int argc, char **argv*/) { char *textBuf = readfile("test.txt"); // 读取输入文件 WcPro wcpro(textBuf);// 将输入文件放入缓冲区 wcpro.processText();// 分析文本,各

软件质量与测试第二周作业 WordCount

第二周作业 WordCount 一.Github 地址 https://github.com/llag9810/Software-Quality-and-Testing-Wordcount 二.PSP2.1 表格 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划 60 25 · Estimate · 估计这个任务需要多少时间 30 15 Development 开发 600 810 · Analysis · 需求分析 (包括学习新技术) 60 60 · D

第4周小组作业:WordCount优化

第4周小组作业:WordCount优化 一.基本任务:代码编写+单元测试 小组github 地址 https://github.com/iwannastay/WcPro PSP表格 PSP2.1 PSP阶段 预估耗时(分钟) 实际耗时(分钟) Planning 计划 30 60 Estimate 估计任务需要多少时间 30 60 Development 开发 180 240 Analysis 需求分析 20 30 Design Spec 生成设计文档 20 30 Design Review 设计

软件测试第二周作业 wordcount

软件测试第二周作业 wordcount Github地址 https://github.com/mxz96102/word_count PSP2.1表格 PSP2.1 PSP 阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划 25 30 · Estimate · 估计这个任务需要多少时间 150 252 Development 开发     · Analysis · 需求分析 (包括学习新技术) 20 20 · Design Spec · 生成设计文档 0 0 · Desig

第6周小组作业:软件测试和评估

第6周小组作业:软件测试和评估 小组成员:胡浪,谢奇光,罗小虎,郭子贤 窗体顶端 1.计划说明 a.我们组选择的两个对比产品是百词斩与扇贝. b.psp表格 项目 内容说明 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划 30 30 · Estimate · 估计这个任务需要多少时间 30 30 Testing Design 测试设计 60 70 · Analysis · 需求和测试需求分析 30 40 · Design Test Cases · 设计测试用例 30 30 Tes

第六周小组作业:软件测试和评估

第六周小组作业:软件测试和评估 一.计划说明 1.产品介绍 本次我们小组测试的是背单词的百词斩app和扇贝记单词app,两者都是市面上比较受欢迎的两个记单词的手机app,测试产品为百词斩,竞品为扇贝记单词,两款产品里面都有丰富的功能,本小组就选取了其中共有的四项功能分别测试,对比,找出各自产品的有点和缺点. psp2.1表格: PSP2.1 PSP 阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划 30 20 · Estimate · 估计这个任务需要多少时间 50 40 T

第二周作业wordcount

github项目链接https://github.com/liqia/WordCount 1.项目简介 对程序设计语言源文件统计字符数.单词数.行数,统计结果以指定格式输出到默认文件中,以及其他扩展功能,并能够快速地处理多个文件. 可执行程序命名为:wc.exe,该程序处理用户需求的模式为: wc.exe [parameter] [input_file_name] 存储统计结果的文件默认为result.txt,放在与wc.exe相同的目录下. 2.项目psp表格 PSP2.1表格 PSP2.1