本文由 @lonelyrains 出品。轉載請註明出處。前端
文章連接: http://blog.csdn.net/lonelyrains/article/details/44225533面試
本篇重點討論基於sql的bug統計分析方法。sql
一、與時間和狀態的關係:svn
1)考察每個時間單位(年、月、日)產生的bug量post
2)考察每個時間單位(年、月、日)解決的bug量
spa
3)考察每個時間單位(年、月、日)遺留的bug量.net
4)考察每個bug遺留的時間單位(年、月、日)code
5)考察平均bug遺留的時間單位(年、月、日)blog
6)經過結合1)、2)、3)考察分析發現、解決bug的時間段(月、日、時)峯值ip
當中6可以用來指導測試、開發效率
二、與時間、角色的關係:
1)考察每個測試每個月發現的bug量
2)考察每個開發每個月解決的bug量
3)考察每個測試自開發提交版本號測試以後,發現每個新bug的時延
4)考察每個開發自測試提交bug以後。解決每個新bug的時延
此1234均可以用來指導績效考覈
三、其它可以考慮與bug發生關係的係數:
1)基於項目劃分
2)基於模塊(硬件、固件、底層軟件、上層應用(前端、後臺)等,依據不一樣項目可以不一樣的劃分狀況)
3)基於功能性質劃分(非致命、通常、界面、崩潰等)
4)基於重現機率劃分
等等
三、高級擴展
1)推斷一個bug是不是難bug,並把它找出來:依據解決時延、反覆reopen的次數、測試和開發者的標註
2)定義每個項目子模塊解決本項目子模塊bug最多的人爲項目子模塊負責人。查詢每個人所負責的項目子模塊數等
四、案例:
使用bugfree。會發現一個問題,所有的bug信息都放在一張表bf_buginfo裏。
ModulePath字段在項目有多個子模塊時,是做爲整字段中間加'/'區分層級的。
如下是我用到的一些SQL統計語句(爲當中一個考察點,筆者在下一篇博客裏專門抽象出一個SQL面試題):
#--查詢bug總體狀況 #select ProjectName,ModulePath,BugTitle,BugStatus,OpenedDate from bf_buginfo order by ProjectName,ModulePath,OpenedDate; #--查詢每個項目的bug數目(XXXX算一個項目) #select count(*),ProjectName from bf_buginfo group by ProjectName having count(*) >= 1; #--查詢XXXX項目每個模塊的bug數目 #select count(*),ModulePath from bf_buginfo where ProjectName like 'XXXX' group by ModulePath having count(*) >= 1; #select * from bf_buginfo where ProjectName like 'XXXX' and ModulePath = '/'; #select BugId,ProjectName,ModulePath,BugTitle,BugStatus,OpenedDate from bf_buginfo order by OpenedDate,ResolvedDate,ClosedDate group by DATE_FORMAT(OpenedDate,'%Y%m'); #--查詢每個月產生的bug數目 #select count(*),DATE_FORMAT(OpenedDate,'%Y-%m') from bf_buginfo group by DATE_FORMAT(OpenedDate,'%Y%m'); #--查詢XXXX每個月產生的bug數目 #select count(*),DATE_FORMAT(OpenedDate,'%Y-%m') from bf_buginfo where ProjectName like 'XXXX' group by DATE_FORMAT(OpenedDate,'%Y%m'); #--查詢XXXXbug高峯期的具體內容 #select ModulePath,BugTitle,BugStatus,OpenedDate,DATE_FORMAT(OpenedDate,'%Y-%m') from bf_buginfo where ProjectName like 'XXXX' and ( DATE_FORMAT(OpenedDate,'%Y%m') = '201310' or DATE_FORMAT(OpenedDate,'%Y%m') = '201406' ); #--查詢XXXXbug狀態狀況 #select count(*),BugStatus from bf_buginfo where ProjectName like 'XXXX' group by BugStatus #--查詢全項目bug狀態狀況 #select count(*),BugStatus from bf_buginfo group by BugStatus #--查詢重難點bug:0基礎過濾方法:從已解決的bug中分析:reopen的 : 需要了解怎樣獲取reopen的記錄 :bf_testaction和bf_buginfo #select count(distinct(bugId)) from Bf_testaction as taction , bf_buginfo as buginfo where ActionType = 'Activated' and taction.idvalue = buginfo.bugid #select count(distinct(bugId)) from bf_testaction as taction , bf_buginfo as buginfo where ActionType = 'Activated' and taction.idvalue = buginfo.bugid and ProjectName like 'XXXX' #activated 226 #activated 138 #--查詢重難點bug:0基礎過濾方法:從已解決的bug中分析:長時間未解決 #690/1695/2715 datediff>=2-fixed/closed/all #select count(*),BugID,ResolvedDate,ProjectName,ModulePath,BugTitle,datediff(ResolvedDate,OpenedDate) from bf_buginfo where bugstatus = 'closed' and datediff(ResolvedDate,OpenedDate) >= 2 and Resolution = 'Fixed' order by ModulePath DESC,BugID DESC #378/927/1248 datediff>=2-fixed/closed/all #ResolvedDate用於對照svn記錄。方便查看 #select BugID,ResolvedDate,ProjectName,ModulePath,BugTitle,datediff(ResolvedDate,OpenedDate) from bf_buginfo where ProjectName like 'XXXX' and bugstatus = 'closed' and datediff(ResolvedDate,OpenedDate) >= 2 and Resolution = 'Fixed' order by ModulePath DESC,BugID DESC #--依據解決人查詢bug #select count(*),ResolvedBy from bf_buginfo where Resolution = 'fixed' and BugStatus = 'closed' group by ResolvedBy order by count(*) #--定義每個項目子模塊解決本項目子模塊bug最多的人爲項目子模塊負責人,查詢每個人所負責的項目子模塊數 select count(*),ResolvedBy from ( select B.* from (select ModulePath, ResolvedBy, count(*) as num from bf_buginfo where Resolution = 'fixed' and BugStatus = 'closed' group by ModulePath, ResolvedBy) B , (select A.ModulePath, MAX(A.num) as num from ( select ModulePath,ResolvedBy,count(*) as num from bf_buginfo where Resolution = 'fixed' and BugStatus = 'closed' group by ModulePath, ResolvedBy ) A group by A.ModulePath ) C where B.ModulePath = C.ModulePath and B.num = C.num order by B.ResolvedBy ) D group by ResolvedBy