結對編程Wordcount
結對夥伴:201631083106 201631063412
項目鏈接:https://gitee.com/monkeyjb/WordCount
作業鏈接:https://edu.cnblogs.com/campus/xnsy/2018softwaretest2398/homework/2187
WordCount新增功能
1 wc.exe -a file.c //返回更復雜的數據(代碼行 / 空行 / 註釋行)
1 //輸出更復雜信息 2 public static String getMoreInfo(String fileName){ 3 int noteLine=0; 4 intemptyLine=0; 5 int codeLine=0; 6 String result; 7 String line; 8 try{ 9 BufferedReader bf=new BufferedReader(new FileReader(fileName)); 10 while((line=bf.readLine())!=null){ 11 if(line.length()>1&&!line.contains("//")){12 codeLine++; 13 }else if (line.length()<=1) { 14 emptyLine++; 15 }else if (line.contains("//")) { 16 noteLine++; 17 } 18 } 19 bf.close(); 20 }catch (Exception e) { 21 e.printStackTrace();22 } 23 result="代碼行/空行/註釋行:"+codeLine+"/"+emptyLine+"/"+noteLine; 24 return result; 25 }
2 wc.exe -e stopList.txt // 停用詞表,統計文件單詞總數時,不統計該表中的單詞。
3 -e 必須與停用詞文件名同時使用,且停用詞文件必須緊跟在-e參數後面,不允許單獨使用-e參數。stopList.txt中停用詞可以多於1個,單詞之間以空格分割,不區分大小寫。
//停用詞表 public static ArrayList<String> stopList(String stopListFile){ ArrayList<String> result=new ArrayList<>(); String line; try{ BufferedReader bf=new BufferedReader(new FileReader(stopListFile)); while((line=bf.readLine())!=null){ String[] stopList=line.split(" "); for(int i=0;i<stopList.length;i++){ result.add(stopList[i]); } } bf.close(); }catch (Exception e) { e.printStackTrace(); } return result; }
5 wc.exe -x //該參數單獨使用,如果命令行有該參數,則程序會顯示圖形界面,用戶可以通過界面選取單個文件,程序就會顯示文件的字符數、單詞數、行數等全部統計信息
互審代碼情況
201631083106:
審查內容:基本版Wordcount,getCharCount(字符計數),getLineCount(行計數),getWordCount模塊(詞計數)
發現問題:代碼上未發現較大錯誤,但是發現註釋較少,認為應該在每個方法前加一定註釋,方便閱讀。
實行註釋之後截圖:
201631063412
審查內容:新增Wordcount功能模塊,getMoreInfo(輸出更復雜信息),stopList(停用詞表),getWordCount(詞計數)
發現問題:功能基本健全,但發現部分命名不規範的情況,如字母未區分大小寫,變量命名為做到見名知意。
進行命名更正後的截圖:
靜態代碼檢查情況
本次靜態代碼審查使用的工具是findbugs,使用方法參考https://blog.csdn.net/strawbingo/article/details/5924005
使用過程中,因本次的代碼量較少,故未發現任何問題,因此截圖略去。
單元測試情況
測試工具:Junit,通過老師在課堂上的介紹,我們采用Junit進行單元測試。Junit的使用十分的方便快捷。
單元測試類:
測試結果:
通過....
黑盒測試
文件夾結構
測試文本文件
停用詞表文件
返回代碼行 / 空行 / 註釋行
加入停用此表後測試
性能測試和優化
性能測試使用工具:Test & Performance Tools Platform (TPTP)
通過在網上查閱相關資料得知,eclipse下可使用tptp對代碼進行性能的測試,參考網站:https://blog.csdn.net/mark_qi/article/details/7794180
本次代碼的性能測試主要使用到的功能有內存分析(Basic Memory Analysis)、執行時間分析(Executeion Time Analysis)、代碼覆蓋(Method Code Coverage)。因項目很小,故程序的內存占用很小,執行時間較短。性能屬於較理想狀態。
結對編程Wordcount