




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、1Chapter 18Testing Conventional ApplicationsSoftware Engineering: A Practitioners Approach, 7/e by Roger S. Pressman2TestabilityOperabilityit operates cleanlyObservabilitythe results of each test case are readily observedControllabilitythe degree to which testing can be automated and optimizedDecomp
2、osabilitytesting can be targetedSimplicityreduce complex architecture and logic to simplify testsStabilityfew changes are requested during testingUnderstandabilityof the design3What is a “Good” Test?A good test has a high probability of finding an errorA good test is not redundant.A good test should
3、 be “best of breed”(所設(shè)計(jì)的測試用例同類最優(yōu)) A good test should be neither too simple nor too complex4Internal and External ViewsAny engineered product can be tested in one of two ways: Knowing the specified function that a product has been designed to perform, tests can be conducted that demonstrate each func
4、tion is fully operational while at the same time searching for errors in each function. (black-box method)Knowing the internal workings of a product, tests can be conducted to ensure that “all gears mesh(所有齒輪都相互嚙合)“, that is, internal operations are performed according to specifications and all inte
5、rnal components have been adequately exercised. (white-box method)5Test Case DesignOBJECTIVECRITERIACONSTRAINTto uncover errorsin a complete mannerwith a minimum of effort and time6Exhaustive Testing(窮舉法)There are 1014 possible paths! If we execute one test per millisecond, it would take 3170 years
6、to test this program!loop 20 X7Selective Testing(選擇法)loop 20 XSelected path8Software TestingMethodsStrategieswhite-boxmethods black-box methods9White-Box Testing. our goal is to ensure that all statements and conditions have been executed at least once .Basis Path Testing (路徑覆蓋測試)Logical Condition T
7、esting (邏輯覆蓋測試)10Basis Path Testing (路徑覆蓋測試)Step1:Draw the flow graph based on the design or the code of program(繪制程序圖).Step 2: Compute the cyclomatic complexity V(G) of the flow graph(計(jì)算程序圖的環(huán)域復(fù)雜度V(G).Step 3: Determine the basis sets of the independent paths (選擇能夠覆蓋所有邊的V(G)條獨(dú)立路徑).Step 4: Design test
8、 cases that will force execution of each independent path in the basis sets(設(shè)計(jì)強(qiáng)制執(zhí)行每條路徑的測試用例集). 2022/7/1811程序圖(flow graph):一種簡化的流程圖,用來考察測試路徑的工具。(1) 程序圖的基本控制結(jié)構(gòu): 結(jié)點(diǎn):代表一條或多條順序執(zhí)行的語句,程序流程圖中的處理方框和菱形判定框可映射為結(jié)點(diǎn)。邊:代表控制流,類似于程序流程圖中的箭頭,(一條邊必須終止于一個結(jié)點(diǎn),即使該結(jié)點(diǎn)并不代表任何語句)封閉區(qū)域:由邊和結(jié)點(diǎn)圈起來的范圍。Basis Path Testing- flow graph202
9、2/7/1812(2)程序圖的結(jié)構(gòu)簡化:程序圖可將順序執(zhí)行的多個結(jié)點(diǎn)合并為1個結(jié)點(diǎn);對流程圖中含有復(fù)合條件的判定框,先分解為幾個簡單條件判定框,再畫程序圖。程序圖關(guān)注的重點(diǎn)是判斷框,而不是執(zhí)行細(xì)節(jié)。(3)程序圖的用途:安排與驗(yàn)證程序的路徑測試;考察與改進(jìn)程序的結(jié)構(gòu)復(fù)雜性。 Basis Path Testing - flow graph2022/7/1813例:畫出下面用PDL描述的程序段的程序圖IF a OR b THEN procedure x ELSE procedure yENDIFqBasis Path Testing - flow graph2022/7/1814分解復(fù)合判斷后的程序
10、圖如下:復(fù)合條件被分解為2個單獨(dú)的結(jié)點(diǎn)a和b。R1和R2是程序圖的2個封閉區(qū)域。qBasis Path Testing- flow graph15Basis Path Testing - cyclomatic complexity we compute the cyclomatic Complexity:1) number of simple decisions + 1 or2) number of enclosed areas + 1In this case, V(G) = 416Basis Path Testing- independent pathsWe derive the indep
11、endent paths:Since V(G) = 4,there are four paths:Path 1: 1,2,3,6,7,8Path 2: 1,2,3,5,7,8Path 3: 1,2,4,7,8Path 4: 1,2,4,7,2,4,.7,8Finally, we derive testcases to exercise these paths.1234567817Basis Path Testing Notesyou dont need a flow chart, but the picture will help when you trace program pathsbas
12、is path testing should be applied to critical modules2022/7/1818實(shí)例:冒泡排序程序,要求:畫出程序流程圖;將程序流程圖轉(zhuǎn)換為程序圖;計(jì)算環(huán)域復(fù)雜度;采用路徑測試法進(jìn)行白盒測試,請?jiān)O(shè)計(jì)測試用例,使其滿足路徑覆蓋。sort(int a ,int n) int i,j,temp; for (i=0;in;i+) for (j=0;jaj+1) temp=aj; aj=aj+1; aj+1=temp; 入口返回injaj+1Yi=i+1j=j+1Y2022/7/1819解:程序流程圖程序圖環(huán)域復(fù)雜度V(G)=判定結(jié)點(diǎn)數(shù)+1 =3+1 =4
13、V(G)=封閉區(qū)域+1 =3+1 =4入口返回injaj+1Yi=i+1j=j+1Y2022/7/1820解(續(xù))設(shè)計(jì)測試用例集使其滿足路徑覆蓋(即:點(diǎn)覆蓋+邊覆蓋) 1)A1=4,6,n=2 2)A2=6,4,2,n=3說明:測試集需覆蓋4條路徑P1:1,2,3,0P2:1,2,3,4,5,9,3,0P3:1,2,3,4,5,6,8,5,9,3,0P4:1,2,3,4,5,6,7,8,5,9,3,0A1覆蓋了P1,P2,P4A2覆蓋了P1,P2,P3入口返回injaj+1Yi=i+1j=j+1Y123465780921Logical Condition Testing(邏輯覆蓋測試)The
14、test case design method that exercises the logical conditions contained in a program module 邏輯覆蓋測試的5種標(biāo)準(zhǔn)(由弱到強(qiáng))(1) 語句覆蓋:每條語句至少執(zhí)行1次;(2) 判定覆蓋:每一判定的每一分支至少執(zhí)行1次;(3) 條件覆蓋:每一判定中的每個條件,分別按“真”和“假”至少各執(zhí)行1次;(4) 判定/條件覆蓋:同時滿足判定覆蓋和條件覆蓋的要求;(5) 條件組合覆蓋:求出判定中所有條件的各種可能的組合值,每一可能的條件組合至少執(zhí)行1次。2022/7/1822利用流程圖中的判定框設(shè)計(jì)測試用例。PROCE
15、DURE EXAMPLE(A,B:REAL;VAR X:REAL) BEGIN IF (A1)AND(B=0) THEN X:=X/A; IF (A=2)OR(X1) THEN X:=X+1 END語句覆蓋測試數(shù)據(jù)如表所示,滿足語句覆蓋準(zhǔn)測。入口返回A1 ANDB=0A=2 ORX1X=X/AX=X+1YYNNABX期望204紅線邏輯覆蓋測試舉例2022/7/1823 判定覆蓋期望結(jié)果應(yīng)該有具體的值,這里用有顏色的線表示。測試數(shù)據(jù)如下表所示,滿足判定覆蓋準(zhǔn)測。語句覆蓋判定覆蓋稱完全覆蓋(路徑覆蓋)。ABX期望204紅線111藍(lán)線入口返回A1 ANDB=0A=2 ORX1X=X/AX=X+1YY
16、NN判定1判定2判定2判定1FTFT邏輯覆蓋測試舉例2022/7/1824 條件覆蓋使每個條件都能取值為真和假。測試數(shù)據(jù)如右下表所示,滿足條件覆蓋準(zhǔn)測。 ABX期望214紅線101藍(lán)線判定2判定1A1B=0A=2X1FFTFTFTT入口返回A1 ANDB=0A=2 ORX1X=X/AX=X+1YYNN判定1判定2邏輯覆蓋測試舉例2022/7/1825 判定/條件覆蓋期望結(jié)果應(yīng)該有具體的值,這里用有顏色的線表示。測試數(shù)據(jù)如右下表所示,滿足判定/條件覆蓋準(zhǔn)測。 判定2判定1FTFTA1B=0A=2X1FFTFTFTT入口返回A1 ANDB=0A=2 ORX1X=X/AX=X+1YYNN判定1判定2
17、ABX期望204紅線111藍(lán)線邏輯覆蓋測試舉例2022/7/1826條件組合覆蓋期望結(jié)果應(yīng)該有具體的值,這里用有顏色的線表示。測試數(shù)據(jù)如右下表所示,滿足多重條件覆蓋準(zhǔn)測。共8種組合條件:(1)A1,B=0(2)A1,B0(3)A1,B=0(4)A1,B0(5)A=2,X1(6)A=2,X1(7)A2,X1(8)A2,X1ABX期望204(1)(5)紅線211(2)(6)綠線102(3)(7)綠線111(4)(8)藍(lán)線入口返回A1 ANDB=0A=2 ORX1X=X/AX=X+1YYNN注意:測試數(shù)據(jù)對黃色路徑并未測試到!如使第2行A=1可覆蓋該路徑。邏輯覆蓋測試舉例2022/7/1827邏輯覆
18、蓋標(biāo)準(zhǔn)的適應(yīng)性分析語句覆蓋:查錯能力最弱,一般不單獨(dú)使用;判定覆蓋與條件覆蓋:一般情況,條件覆蓋優(yōu)于判斷覆蓋。但也可能出現(xiàn):滿足條件覆蓋,但卻不滿足判斷覆蓋的情況。判定/條件覆蓋:彌補(bǔ)條件覆蓋的缺陷;條件組合覆蓋:在5種覆蓋中查錯能力最強(qiáng),凡是滿足條件組合覆蓋的測試數(shù)據(jù),必然滿足其余4種覆蓋。2022/7/1828例子:按邏輯覆蓋標(biāo)準(zhǔn)的要求設(shè)計(jì)冒泡程序的測試用例輸入:k(序列長度),Ak(無序數(shù)據(jù))輸出:Ak(有序數(shù)據(jù)) FOR i:=2 TO k DO IF ai = ai-1 THEN FOR j:=i DOWNTO 2 DO IF aj = aj-1 THEN temp := aj; a
19、j := aj-1; aj-1 := temp; ENDIF ENDDO ENDIF ENDDO2022/7/18291) 語句覆蓋:每條語句至少執(zhí)行1次。測試用例:A=8,4,K=2,可滿足程序執(zhí)行時遍歷流程圖所有框的要求。潛在問題:若2個判定框中的“=”誤寫為“AI-1、AI=AI-1、AIAJ-1、AJ=AJ-1、AJAJ-1的情況至少出現(xiàn)一次。測試用例:A=8,4,9,6,K=4、A=8,4,8,4, K=4。 可合并為:A=8,4,8,4,9,6,K=64) 判定/條件覆蓋:同時滿足判定覆蓋和條件覆蓋的要求。 分析:該例中的2個復(fù)合判斷條件(=)并不獨(dú)立,即若為“真”,則必為“假”,
20、反之亦然。故考慮判定/條件覆蓋沒有實(shí)際意義。5)條件組合覆蓋:求出判定中所有條件的各種可能的組合值,每一可能的條件組合至少執(zhí)行1次。 分析:同上,考慮條件組合覆蓋沒有實(shí)際意義。例子:按邏輯覆蓋標(biāo)準(zhǔn)的要求設(shè)計(jì)冒泡程序的測試用例2022/7/1831組合條件測試的路徑選擇當(dāng)程序中判定多于一個時,形成的分支結(jié)構(gòu)可分為嵌套型分支結(jié)構(gòu)和連鎖型分支結(jié)構(gòu)。對于嵌套型分支結(jié)構(gòu),若有n個判定語句,需要n+1個測試用例;對于連鎖型分支結(jié)構(gòu), 若有n個判定語句,需要有2n個測試用例,覆蓋它的2n條路徑。2022/7/1832組合條件測試的路徑選擇33Loop TestingNested LoopsConcatena
21、ted (連鎖型)Loops Unstructured LoopsSimple loop34Loop Testing: Simple LoopsMinimum conditionsSimple Loops1. skip the loop entirely2. only one pass through the loop3. two passes through the loop4. m passes through the loop m n5. (n-1), n, and (n+1) passes through the loopwhere n is the maximum number of
22、 allowable passes35Loop Testing: Nested LoopsStart at the innermost loop. Set all outer loops to their minimum iteration parameter values.Test the min+1, typical, max-1 and max for the innermost loop, while holding the outer loops at their minimum values.Move out one loop and set it up as in step 2,
23、 holding all other loops at typical values. Continue this step until the outermost loop has been tested.If the loops are independent of one another then treat each as a simple loop else* treat as nested loopsendif* for example, the final loop counter value of loop 1 is used to initialize loop 2.Nest
24、ed LoopsConcatenated Loops36Black-Box Testingrequirementseventsinputoutput37Black-Box TestingHow is functional validity tested?How is system behavior and performance tested?What classes of input will make good test cases?Is the system particularly sensitive to certain input values?How are the bounda
25、ries of a data class isolated?What data rates and data volume can the system tolerate?What effect will specific combinations of data have on system operation?38Black-Box TestingBlack-box testing attempts to find errors in the following categories: incorrect or missing functionsinterface errorserrors
26、 in data structures or external database accessbehavior or performance errors39Equivalence Partitioning(等價類劃分)userqueriesmousepicksoutputformatspromptsFKinputdataEquivalence partitioning is a black-box testing method that divides the input domain of a program into classes of data from which test cas
27、es can be derived. An ideal test case uncovers a class of errorsEquivalence Partitioning等價類劃分 把全部輸入數(shù)據(jù)合理劃分為若干等價類,使每一等價類中的任何一個測試用例,都能代表該類中的其它測試用例。從而可用少量代表性測試數(shù)據(jù),取得較好的測試效果。用例設(shè)計(jì)要點(diǎn):在設(shè)計(jì)測試用例時,必須同時考慮有效等價類和無效等價類;每一無效等價類至少用一個測試用例,但允許若干有效等價類合用一個測試用例。4041Sample Equivalence Classesuser supplied commandsresponses
28、to system promptsfile namescomputational data physical parameters bounding values initiation valuesoutput data formattingresponses to error messagesgraphical data (e.g., mouse picks)data outside bounds of the program physically impossible dataproper value supplied in wrong placeValid dataInvalid dat
29、a42例:一個程序的功能描述如下,用等價類劃分法設(shè)計(jì)測試用例。功能描述:某城市的電話號碼由3部分組成。要求被測程序能接收一切符合下述規(guī)定的電話號碼,拒絕所有不符合規(guī)定的電話號碼。區(qū)號:空白或3位數(shù)字;前綴:非0或1開頭的4位數(shù)字;后綴:4位數(shù)字。輸入條件有效等價類無效等價類區(qū)碼空白(1);3位數(shù)字(2)有非數(shù)字字符(5);少于3位數(shù)字(6);多于3位數(shù)字(7) 前綴從2000到9999的3位數(shù)字(3)有非數(shù)字字符(8);少于4位數(shù)字(9);多于4位數(shù)字(10)起始位為0(11); 起始位為1(12)后綴4位數(shù)字(4)有非數(shù)字字符(13);少于4位數(shù)字(14);多于4位數(shù)字(15)測試用例測試范
30、圍期望結(jié)果 6510 2345等價類(1) (3) (4) 有效023 6511 1321等價類(2) (3) (4)有效20# 1234 4356等價類(5)無效剩下的10個用例無效等價類(6)-(15) 無效測試用例的設(shè)計(jì):43Boundary Value Analysis(邊界值分析)userqueriesmousepicksoutputformatspromptsFKinputdataoutputdomaininput domainA greater number of errors occurs at the boundaries of the input domain rather than in the “center.” Boundary value analysis leads to a selection of test cases that exercise bounding val
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 教練和女兒私下協(xié)議書
- 咖啡廳加盟合同協(xié)議書
- 財(cái)產(chǎn)賬戶協(xié)議書
- 藥店變更協(xié)議書
- 郵儲就業(yè)協(xié)議書
- 屠宰檢疫員合同協(xié)議書
- 合同外增加工程協(xié)議書
- 郵寄快遞協(xié)議書
- 液化氣供氣合同協(xié)議書
- 美國導(dǎo)彈協(xié)議書
- 高中英語新人教版必修三全冊單詞(按單元順序)默寫版(含答案)
- 施工鋼結(jié)構(gòu)制作安裝環(huán)境因素識別表
- 污水井巡查記錄表
- 2關(guān)于更換現(xiàn)場項(xiàng)目經(jīng)理的函
- 部編版小學(xué)道德與法治四年級下冊期末復(fù)習(xí)簡答及分析題專練(含答案)
- 電子商務(wù)那些事學(xué)習(xí)通超星課后章節(jié)答案期末考試題庫2023年
- 環(huán)境及理化因素?fù)p傷-凍傷
- Unit7SeasonPartALetslearn(教學(xué)設(shè)計(jì))閩教版英語四年級下冊
- 世界文化遺產(chǎn)武當(dāng)山古建筑群的資料
- 醫(yī)院醫(yī)療設(shè)備采購項(xiàng)目HIS系統(tǒng)及硬件采購?fù)稑?biāo)文件
- 【橡膠工藝】-橡膠產(chǎn)品生產(chǎn)工藝規(guī)程
評論
0/150
提交評論