码迷,mamicode.com
首页 > 其他好文 > 详细

第四周小组作业

时间:2018-04-08 18:24:33      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:throw   tab   null   选择   测试结果   ica   text   .com   author   

一、项目GitHub地址

https://github.com/fanhao300/Test-QualityGroupWprk

二、项目PSP表格

 

PSP2.1表格

PSP2.1

PSP阶段

预估耗时

(分钟)

实际耗时

(分钟)

Planning

计划

   

· Estimate

· 估计这个任务需要多少时间

425  400

Development

开发

   

· Analysis

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

 30  30

· Design Spec

· 生成设计文档

 60 45 

· Design Review

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

 30 20 

· Coding Standard

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

 30 30 

· Design

· 具体设计

 30 30 

· Coding

· 具体编码

 45 30 

· Code Review

· 代码复审

 30 30 

· Test

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

 60 75 

Reporting

报告

   

· Test Report

· 测试报告

 60 45 

· Size Measurement

· 计算工作量

 20 20 

· Postmortem & Process Improvement Plan

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

 30 30 
 

合计

 425 400 

三、个人接口及其实现

  个人在小组的任务是输出模块的编码以及单元测试

   输出模块由两个类组成,一个是Item类,第二个是print类。其中Item类中的结构体变量item中有namehe value两个属性,用来接收分析出来的单词和词频。

  Print类用来构造整个输出的ArrayList<Item>数组,以及把数组写入到result.txt文件。

 1 public class Item {
 2     String name;
 3     int value;
 4     
 5     public Item(String name, int value) {
 6         super();
 7         this.name = name;
 8         this.value = value;
 9     }
10     public String getName() {
11         return name;
12     }
13     public void setName(String name) {
14         this.name = name;
15     }
16     public int getValue() {
17         return value;
18     }
19     public void setValue(int value) {
20         this.value = value;
21     }
22     
23 }

 

 1 public class Print {
 2     private static ArrayList<Item> itemList=new ArrayList<Item>();
 3 
 4     public  ArrayList<Item> getItemList() {
 5         return itemList;
 6     }
 7     public  void setItemList(ArrayList<Item> itemList) {
 8         Print.itemList = itemList;
 9     }
10     
11     
12     public void output() throws IOException {
13             String line="";
14             FileOutputStream out=new FileOutputStream("result.txt");
15             for(int i=0;i<itemList.size();i++) {
16                 Item pp=itemList.get(i);
17                 line=pp.getName()+","+pp.getValue()+"\n";
18                 out.write(line.getBytes()); 
19             }
20             out.close();    
21     }    
22 }

 

 四、测试用例的设计

       输出模块的测试,给ArrayLis<Item>附上一定的值,然后读书result.txt 文件中的数组,和自己的输入作比较。

以下是测试代码的举例:

 1 public class PrintTest {
 2     @Ignore
 3     @Test
 4     public void testGetItemList() {
 5         fail("Not yet implemented");
 6     }
 7     @Ignore
 8     @Test
 9     public void testSetItemList() throws IOException {
10         
11     }
12     @Test
13     public void testOutput() throws IOException {
14         Print pr=new Print();
15         ArrayList<Item> itemList=new ArrayList<Item>();
16         itemList.add(new Item("LIshuai",30));
17         itemList.add(new Item("liwej",23));
18         itemList.add(new Item("qqqqqi",20));
19         itemList.add(new Item("sfwf_fwr",18));
20         itemList.add(new Item("fsaggw",10));
21         itemList.add(new Item("fzxzc",9));
22         itemList.add(new Item("asdcf",8));
23         pr.setItemList(itemList);
24         pr.output();
25         Scanner s=new Scanner(new File("result.txt"));
26         String str1=s.nextLine();
27         assertEquals("LIshuai,30",str1);
28         String str2=s.nextLine();
29         assertEquals("liwej,23",str2);
30         String str3=s.nextLine();
31         assertEquals("qqqqqi,20",str3);
32         String str4=s.nextLine();
33         assertEquals("sfwf_fwr,18",str4);
34         String str5=s.nextLine();
35         assertEquals("fsaggw,10",str5);
36         String str6=s.nextLine();
37         assertEquals("fzxzc,9",str6);
38         String str7=s.nextLine();
39         assertEquals("asdcf,8",str7);
40         fail("Not yet implemented");
41         s.close();
42     }
43 
44 }

 

五、测试用例的运行截图

测试用例分别给value和name赋不同的值,分别写了十多个不同的测试用例的类。下面是某一测试结果的截图

技术分享图片

六、小组贡献分

0.24

七、扩展项目

1,我们小组选择的是  阿里巴巴Java开发手册

2,我分析了我们小组彭士远(U201517129)的代码,他负责的是输入部分。

import java.io 

.*;


/**
 * 
 * @author 彭士远  
 * 
 */
public class Inputcheck {
    private static final String HOUZHUI = ".txt";
    private static final int MATCHLENGTH = 4;
    public File check(String filename) {
        File filePath = new File(filename);
        if(filePath.exists()) {
            if(!(filename.substring((filename.length() - MATCHLENGTH), filename.length()).equals(HOUZHUI))) {
                filePath = null;
            }
        }else {
            filePath = null;
        }
        return filePath;
    }
}

 

他的代码大部分都很规范,就是没有写@author的注释。

3,我们选择的静态工具是阿里巴巴静态扫描工具

网址:https://p3c.alibaba.com/plugin/eclipse/update

4,扫描后出现的问题就是没有加注释,再加入注释后没有显示不规范。

技术分享图片

5,整个小组的代码除了没加@author的注释外,没有问题。

 

 

 
 
 
 import 技术分享图片java.io 

.*;


/**
 * 
 * @author 彭士远  
 * 
 */
public class Inputcheck {
private static final String HOUZHUI = ".txt";
private static final int MATCHLENGTH = 4;
public File check(String filename) {
File filePath = new File(filename);
if(filePath.exists()) {
            if(!(filename.substring((filename.length() - MATCHLENGTH), filename.length()).equals(HOUZHUI))) {
             filePath = null;
}
}else {
filePath = null;
}
return filePath;
}

第四周小组作业

标签:throw   tab   null   选择   测试结果   ica   text   .com   author   

原文地址:https://www.cnblogs.com/lakshy/p/8745838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!