【文档说明】软件工程实践者的研究方法chapter15cn传统软件测试课件.pptx,共(42)页,186.077 KB,由小橙橙上传
转载请保留链接:https://www.ichengzhen.cn/view-45056.html
以下为本文档部分文字说明:
软件工程实践者的研究方法chapter15cn传统软件测试课件测试的原则•原则一:穷尽测试是不可能的•原则二:测试工作具有创造性和挑战性•原则三:测试旨在发现存在的缺陷•原则四:测试是有风险的•原则五:测试需要有计划性•原则六:测试需要
有独立性测试生存周期测试计划测试设计测试开发测试执行测试评估测试条件、资源、进度设计测试用例(确定怎么测试)测试开发(设计脚本、桩和驱动模块等)建立测试环境,运行被测程序,执行测试将测试结果与期望结果进行比较测试计划、测试设计和测试开发在软件开发
完成前进行测试执行只能在软件开发完成后进行1)测试计划•测试计划主要内容:–测试目标–测试策略–测试参与人员–测试的进度安排–测试的系统环境Review测试计划模板2)测试设计•任务:设计测试用例•测试用例(t
estcase)是按一定顺序执行的与测试目标相关的一系列测试。其主要内容包括:–测试输入(Testinput)–期望结果(ExpectedResults)•测试用例设计的两种通用方法–白盒测试:依据源代码–黑盒测试:依据需求举例:采用黑盒法设计测试
用例•一个加法程序intAdd(inta,intb)的测试用例–测试输入(Testinput)•输入a为2,b为3–期望结果(ExpectedResults)•输出结果为5举例:采用白盒法设计测试用例•语句覆盖法–使得程序中的每一个语
句至少被遍历一次•测试用例:A=2,B=0,X=3A>1ANDB=0aYcX=X/ANbYeX=X+1NdA=2ORX>13)测试开发•任务:开发测试脚本、桩和驱动模块•TestScipt:Inmanualtesting,theinstructionson
howtoperformoneormoretestcases,alsooftencalledatestprocedure.Inautomatedtesting,referstothecorrespondingmachine-executable
instructions.•TestCase:Asequenceofstepsconsistingofactionstobeperformedonthesystemundertest.(Thesestepsaresometimescalledthetestprocedu
reortestscript.)Theseactionsareoftenassociatedwithsomesetofdata(preloadedorinputduringthetest).Thecombinationofactionstakenanddataprovidedtothes
ystemundertestleadstothetestcondition.Thisconditiontendstoproduceresultsthatthetestcancomparewiththeexpectedresu
lts;i.e.,assessqualityunderthegiventestcondition.Theactionscanbeperformedserially,inparallel,orinsomeotherco
mbinationofconsecution.4)测试执行•任务:执行测试用例•对于手动测试:–测试者按事先准备好的手工过程进行测试,测试者输入数据、观察输出、记录发现的问题。•对于自动测试:–可能只需要启动
测试工具,并告诉工具执行哪些测试用例。5)测试评估•任务:将测试结果与期望输出进行比较,判断软件功能是否正确,编写缺陷报告和测试记录•软件缺陷(bug)是对软件产品预期属性的偏离–对产品需求规约的偏离–对用户期望的偏离,即用户要求未体现在需求规约中–
软件做了用户不希望做的事(画蛇添足)缺陷等级•0级:灾难性的--系统崩溃、数据被破坏•1级:很严重的--数据被破坏•2级:严重的--特性不能运行,无法替代•3级:中等的--特性不能运行,可替代•4级:烦恼的--提示不正确,报警不确切•5级:轻
微的--表面化的错误,拼写错等缺陷报告(BugReport)•项目名称•测试日期•测试人•缺陷等级•缺陷描述回归测试•为了保证软件返工时没有引进新的错误,要全部或部分地重复以前做过的测试。终止测试的标准•在测试计划中规定终止
测试的标准•终止测试的常用标准–所有严重的缺陷都已纠正,剩余的缺陷密度少于0.01%–100%测试覆盖度–至少要查出***缺陷数量–1000个CPU小时内不出错的操作概率大于99.5%Testability•Operability—itoperate
scleanly•Observability—theresultsofeachtestcasearereadilyobserved•Controllability—thedegreetowhichtestingcanbeautomatedandoptimized•Dec
omposability—testingcanbetargeted•Simplicity—reducecomplexarchitectureandlogictosimplifytests•Stability—fewchangesarerequestedduringtesting•Unders
tandability—ofthedesignWhatisa―Good‖Test?•Agoodtesthasahighprobabilityoffindinganerror•Agoodtestisnotredund
ant.•Agoodtestshouldbe―bestofbreed‖•AgoodtestshouldbeneithertoosimplenortoocomplexInternalandExternalViews•Anyengineeredpr
oduct(andmostotherthings)canbetestedinoneoftwoways:–Knowingthespecifiedfunctionthataproducthasbeendesignedtoperform,testscanbeconductedthatdemonst
rateeachfunctionisfullyoperationalwhileatthesametimesearchingforerrorsineachfunction;–Knowingtheinternalworkingsofaproduct,testscanbeconductedtoT
estCaseDesign"Bugslurkincornersandcongregateatboundaries..."BorisBeizerOBJECTIVECRITERIACONSTRAINTtouncovererrorsinacompletemannerwithaminimumofef
fortandtime穷尽测试——可能吗?loop<20XThereare10possiblepaths!Ifweexecuteonetestpermillisecond,itwouldtake3,170yearstotestthisprogram!!1
4选择性测试loop<20XSelectedpathSoftwareTestingMethodsStrategieswhite-boxmethodsblack-boxmethods黑盒测试和白盒测试•黑盒测试–根据被测试程序功能来进行测试
•等价分类法•边界值分析法•错误猜测法•白盒测试–以程序结构为依据的测试方法•逻辑覆盖法•路径测试法白盒测试...我们的目标是确保所有的语句与条件至少被执行一次。为什么需要覆盖?错误与路径执行的可能性成反
比我们经常确信某个路径不会被执行,事实往往相反。基本路径测试First,wecomputethecyclomaticcomplexity:numberofsimpledecisions+1ornumberofenclosedareas+1Inthiscase,V(G)=4C
yclomaticComplexityAnumberofindustrystudieshaveindicatedthatthehigherV(G),thehighertheprobabilityorerrors.V(G)modulesmodulesi
nthisrangearemoreerrorprone基本路径测试Next,wederivetheindependentpaths:SinceV(G)=4,therearefourpathsPath1:1,2,3,6,7,8Path2:1,2,3,5,7
,8Path3:1,2,4,7,8Path4:1,2,4,7,2,4,...7,8Finally,wederivetestcasestoexercisethesepaths.12345678BasisPathTestingNotesyoudon'tneedaflow
chart,butthepicturewillhelpwhenyoutraceprogrampathscounteachsimplelogicaltest,compoundtestscountas2or
morebasispathtestingshouldbeappliedtocriticalmodulesDerivingTestCases•Summarizing:–Usingthedesignorcodeasafoundation,drawac
orrespondingflowgraph.–Determinethecyclomaticcomplexityoftheresultantflowgraph.–Determineabasissetoflinearlyindepend
entpaths.–Preparetestcasesthatwillforceexecutionofeachpathinthebasisset.控制结构测试•条件测试—atestcasedesignmethodthatexercisesthelogicalconditionscontain
edinaprogrammodule•数据流测试—selectstestpathsofaprogramaccordingtothelocationsofdefinitionsandusesofvariablesintheprogramDataFlowTesting
•Thedataflowtestingmethod[Fra93]selectstestpathsofaprogramaccordingtothelocationsofdefinitionsandusesofvariablesintheprogram.–Assumethateachstateme
ntinaprogramisassignedauniquestatementnumberandthateachfunctiondoesnotmodifyitsparametersorglobalvariables.ForastatementwithSasitsstatementnumber•D
EF(S)={X|statementScontainsadefinitionofX}•USE(S)={X|statementScontainsauseofX}–Adefinition-use(DU)chainofvariableXisoftheform[X,S,S
'],whereSandS'arestatementnumbers,XisinDEF(S)andUSE(S'),andthedefinitionofXinstatementSisliveatstatem
entS'LoopTestingNestedLoopsConcatenatedLoopsUnstructuredLoopsSimpleloopLoopTesting:SimpleLoopsMinimum
conditions—SimpleLoops1.skiptheloopentirely2.onlyonepassthroughtheloop3.twopassesthroughtheloop4.mpassesthroughtheloopm<n5.(n-1),n,and(n+1)passesth
roughtheloopwherenisthemaximumnumberofallowablepassesLoopTesting:NestedLoopsStartattheinnermostloop.Setallouterloopstotheirminimumi
terationparametervalues.Testthemin+1,typical,max-1andmaxfortheinnermostloop,whileholdingtheouterloopsattheirminimumvalues.Moveou
toneloopandsetitupasinstep2,holdingallotherloopsattypicalvalues.Continuethisstepuntiltheoutermostloophasbeen
tested.Iftheloopsareindependentofoneanotherthentreateachasasimpleloopelse*treatasnestedloopsendif*forexample,thefinallo
opcountervalueofloop1isusedtoinitializeloop2.NestedLoopsConcatenatedLoopsBlack-BoxTestingrequirementseventsinputoutputBlack-BoxTestin
g•Howisfunctionalvaliditytested?•Howissystembehaviorandperformancetested?•Whatclassesofinputwillmakegoodtestcases?•Isthesyst
emparticularlysensitivetocertaininputvalues?•Howaretheboundariesofadataclassisolated?•Whatdataratesanddat
avolumecanthesystemtolerate?•Whateffectwillspecificcombinationsofdatahaveonsystemoperation?黑盒测试•等价分类法(equivalencepartitioning)–把输入数据的可能值
划分为若干等价类–有效等价类和无效等价类–每一无效等价类至少需要一个测试用例•例子某工厂公开招工,规定报名者年龄应在16周岁至35周岁之间(到2008年3月止)即出生年月不在上述范围内,将拒绝接受,并显示“年龄不合格”等出错信息。黑盒测试•边界值分析法(bo
undaryvalueanalysis)–使被测程序在边界值及其附近运行,从而更有效地暴露程序中潜藏的错误•错误猜测法(errorguessing)–猜测被测程序在哪些地方容易出错–针对可能的薄弱环节来设计测试用例Equivalenc
ePartitioninguserqueriesmousepicksoutputformatspromptsFKinputdataSampleEquivalenceClassesusersupplied
commandsresponsestosystempromptsfilenamescomputationaldataphysicalparametersboundingvaluesinitiationvaluesoutputdataformattin
gresponsestoerrormessagesgraphicaldata(e.g.,mousepicks)dataoutsideboundsoftheprogramphysicallyimpossibledatapropervaluesuppliedinwrongpl
aceValiddataInvaliddataBoundaryValueAnalysisuserqueriesmousepicksoutputformatspromptsFKinputdataoutputdomaininputdomain