标签:gmm str ble stat spec stringbu for bsp exception
GitHub链接
https://github.com/Wangmmmm/WordCountPro.git
请查看我的测试时切到 package 分支!
PSP2.1表格
|
PSP2.1 |
PSP阶段 |
预估耗时 (分钟) |
实际耗时 (分钟) |
|
Planning |
计划 |
5 | 5 |
|
· Estimate |
· 估计这个任务需要多少时间 |
180 | 320 |
|
Development |
开发 |
120 | 320 |
|
· Analysis |
· 需求分析 (包括学习新技术) |
10 | 60 |
|
· Design Spec |
· 生成设计文档 |
10 | 10 |
|
· Design Review |
· 设计复审 (和同事审核设计文档) |
10 | 10 |
|
· Coding Standard |
· 代码规范 (为目前的开发制定合适的规范) |
10 | 10 |
|
· Design |
· 具体设计 |
10 | 10 |
|
· Coding |
· 具体编码 |
30 | 30 |
|
· Code Review |
· 代码复审 |
10 | 10 |
|
· Test |
· 测试(自我测试,修改代码,提交修改) |
30 | 180 |
|
Reporting |
报告 |
40 | 45 |
|
· Test Report |
· 测试报告 |
10 | 15 |
|
· Size Measurement |
· 计算工作量 |
10 | 10 |
|
· Postmortem & Process Improvement Plan |
· 事后总结, 并提出过程改进计划 |
20 | 20 |
|
合计 |
165 | 370 |
接口实现
主要负责对输入的路径进行分析判断是否合法和可读,如果可读就将文件内容读取出来,并调用核心模块的状态接口。
public static boolean ReadContent(String path)throws Exception{
//参数判断
if(path==null||path.isEmpty()||path.length()==0){
System.out.print("empty path!");
return false;
}
//格式判断
if(!IsTxtFormat(path)){
System.out.print("error format!");
return false;
}
StringBuilder stringBuilder=new StringBuilder();
File file=new File(path);
//文件存在判断
if(!file.exists()){
System.out.println("file not exist");
return false;
}
FileReader reader=new FileReader(file);
StringBuilder wordStringBuilder=new StringBuilder();
int tempChar;
Statistics st=new Statistics();
//内容读取
while((tempChar=reader.read())!=-1){
//接口调用
st.Count((char)tempChar);
}
reader.close();
st.End();
fileContent=stringBuilder.toString();
//读取结束,给出反馈
System.out.println("read file success!");
return true;
}
测试用例
//测试是否读取正常,包括路径的判断和参数判断
@Test
public void testReadContent() throws Exception {
//设置测试参数
String pathes[]={"d:/test.txt","d:test.doc","test.txt","test.doc",""," "};
//设置预期输出
boolean[] expResult={true,false,false,false,false,false};
int pathCount=pathes.length;
boolean [] results=new boolean[pathCount];
for(int i=0;i<pathCount;i++){
//存储测试结果
results[i]= InputMod.ReadContent(pathes[i]);
}
for(int i=0;i<pathCount;i++){
//结果对比
Assert.assertEquals("error",expResult[i],results[i]);
}
//TODO: Test goes here...
}
//格式判断,测试是否能正确判断输入文件的格式
@Test
public void testIsTxtFormat() throws Exception {
//TODO: Test goes here...
String pathes[]={".txt",". txt"," .txt",""," ",".doc"};
boolean[] expResult={true,false,true,false,false,false};
int pathCount=pathes.length;
boolean [] results=new boolean[pathCount];
for(int i=0;i<pathCount;i++){
results[i]= InputMod.IsTxtFormat(pathes[i]);
}
for(int i=0;i<pathCount;i++){
Assert.assertEquals("error",expResult[i],results[i]);
}
}
测试用例表格

测试运行截图
静态测试



小组讨论评分
0.25
标签:gmm str ble stat spec stringbu for bsp exception
原文地址:https://www.cnblogs.com/Donoth/p/8719588.html