IMSchach8thedChap06v6.docx
- 文档编号:11353687
- 上传时间:2023-05-31
- 格式:DOCX
- 页数:25
- 大小:116.62KB
IMSchach8thedChap06v6.docx
《IMSchach8thedChap06v6.docx》由会员分享,可在线阅读,更多相关《IMSchach8thedChap06v6.docx(25页珍藏版)》请在冰点文库上搜索。
IMSchach8thedChap06v6
Chapter6
Testing
Themajorthemeofthischapteristhattestingisnotaseparatephaseofthelifecycle,butanactivitythatmustbecarriedoncontinuouslythroughoutthelifecycle,fromthebeginningtotheend.
Itisimportantthattwodistinctionsbecarefullydrawn.Thefirstisthekeydifferencebetweenexecution-basedandnon-execution-basedtesting.Formanystudents,theveryideaofnon-execution-basedtestingisdifficulttocomprehend.Thesecondisthekeydifferencebetweentestingandcorrectnessproving.Evenstudentswithoutcollege-levelmathematicscanunderstandthecorrectnessproofofSection6.5.1.
Problemsolutions
6.1:
Correctnessprovingistheuseofmathematicalprooftechniquestoshowthattheproductsatisfiesitsspecifications.
Verificationisusedintwoways,namely(a)non-execution-basedtesting,and(b)theprocessofdeterminingthataspecificactivityhasbeencompletedcorrectly.
Validationistheprocessofdeterminingwhethertheproductasawholesatisfiesitsrequirements.
6.2:
Iftheorganizationisrestructuredsothat24professionals,includingfivemanagers,areconcernedsolelywithSQA,increasedproductivityandproductqualitycanbeexpected.Thecoststothecompanywillincludereorganizationtime(twoday’slabor,approximately73⨯$925+18⨯$1,250,orabout$90,000)andtrainingtimeandcostsforthefiveSQAmanagers(perhaps$75,000).Thetotalcostofabout$165,000shouldberecoupedinayearevenifproductivityincreasesbyonly3%.
6.3:
Supposethatproductdevelopmentisdonebysixprofessionalsincludingtwomanagers,whereasSQAisdonebytheotheroneprogrammerandtheothermanager.Reorganizationcostsarenowabout$8,375(thatis,lessthanonetenthofthecostsforProblem6.2),andtrainingcostsforonlyonemanagerareabout$15,000.Againthetotalcostshouldsoonberecouped.
6.4:
Assumingthatgoodtestingtechniqueshavebeenused,itisunlikelythatthereareanyfurtherfaults.
6.5:
Botharereviewprocessesperformedbyteamswiththeaimoffindingfaults.Inbothcases,thematerialisstudiedbyindividualteammembers,andthenthematerialisreviewedbytheteamasagroup.
Themajordifferencesare:
aninspectionisaformalfive-stepprocesswhereasawalkthroughhastwoinformalsteps;previouslyacquiredfaultstatisticsplayanimportantroleintheinspectionprocess;thereisaformalcomponentoftheinspectionprocessforensuringthatallfaultsnotedarelatercorrected;ifmorethanacertainfractionofthematerialischangedthenitmustbesubmittedforreinspection.
6.6:
TheresultsoftheexperimentscitedinSection6.2.3showthatinspectionsbothdetectfaultsandsavemoney.
6.7:
Utility:
Isiteasytouse?
Howmuchtrainingisneededforthepackagetobeusedeffectively?
Howeasyisthedocumentationtounderstand?
Istheproductreasonablypricedcomparedtosimilarproductsonthemarket?
Doesithavealltheneededfeatures?
Reliability:
Howfrequentlydoestheproductfail?
Whataretheresultsofsuchafailure,andhoweasyisittoresumework?
Robustness:
Howdoestheproductreacttoinvalidinputdata?
Whathappensifthemachineisturnedoffwhiledataisinthecourseofbeingentered?
Whathappensiftheuserbangsonthekeyboardinthemiddleofacomputation?
Performance:
Cantheproductkeepupwithourfastestclerks?
Canithandleourlargestdocuments?
Whatprintersdoesitsupport?
Ifitcanhandlespooling,howmanydocumentscanitspoolatonce?
Whatareitsnetworkingcapabilities?
Whatisitsresponsetimeunderpeakload?
Correctness:
Doesitfunctioncorrectly?
Arethecommandscorrectlydescribedintheusermanual?
Doesitcorruptfilesinanyway?
6.8:
Utility:
Isiteasytouse?
Whattypesofencryptionaresupported?
Canittransferdatabetweendifferenttypesofhardware?
Isiteconomicallypricedcomparedtosimilarproductsonthemarket?
Reliability:
Howaccurateisthetransmissionofbothlargeandsmallfiles?
Robustness:
Whathappensifasinglenodeoracombinationofnodesgoesdown?
Howtolerantoflinenoiseandspikesonthelineistheproduct?
Performance:
Whatspeedsofdatatransferaresupported?
Howdoesperformancedegradeunderincreasedload?
Doestheproductdegradegracefullywithoutlossofreliability?
Howsecureisthenetwork?
Whatarethelargestfileandthesmallestfilethatmaybetransferred?
Correctness:
Doestheproducttransferfilesaslaiddowninthespecifications?
6.9:
Utility:
Isiteasytouse?
Whattrainingisneededbeforeusingit?
Isthetrainingmanualeasytofollow?
Reliability:
Ifaimedcorrectly,doesitstrikethetargeteverytime?
Doesitexplodeinflight?
Robustness:
Whathappensifthemissileisdropped?
Howdoesitfunctionunderbattleconditions?
Performance:
Howaccurateisthemissile?
Isitsexplosivepoweradequatetodestroyanyship?
Willanear-missdisableaship,andifso,underwhatconditions?
Howmuchtimeelapsesbetweenthesightingofatargetandthemissilebeinglaunched?
Canitcopewithevasiveactiononthepartofthetargetship?
Correctness:
Doestheproductfunctionaslaiddowninitsspecifications?
6.10:
AnannotatedflowchartisshowninFigure6.1.
TheinputspecificationisP:
n∈{1,2,3,…}.Itclearlyholdsatallpointsontheflowchart,andisomittedelsewhereforsimplicity.
TheloopinvariantS:
k ≤ nandg = k!
holdsthefirsttimetheloopisentered,becausek = 0and0!
= 1.AssumethatitholdsatSforsomek = k0.Then,ifk0 ≥ ntheloopterminates,andtheoutputconditionissatisfiedatW.Ifnot,thencontrolpassestoT;asaresultofthefailedconditional,k0 < n.Also,g = k0!
byhypothesis.
AtU,thevalueofk0hasbeenincreasedby1,andthusk0 ≤ nandg = (k0 – 1)!
asindicatedontheflowchart.AtV,ghasbeenmultipliedbyk0.TheassertionatVfollowsfromthefactthatk0 ⨯ (k0 – 1)!
=k0!
Figure6.1.AnnotatedflowchartofcodefragmentofProblem6.12.
TheassertionatpointVisidenticaltotheassertionthat,byhypothesis,holdsatpointS.ButpointSistopologicallyidenticaltopointV.Byinductionitfollowsthattheloopinvariantholdsforallvaluesofk,0 ≤ k ≤ n.
Allthatremainsistoprovethattheloopterminates.Initiallythevalueofkisequalto0.Eachtimetheloopisiteratedthevalueofkisincreasedby1bythestatementk ← k + 1.Asaconsequenceoftheloopinvariant,kcannotexceedn.Eventuallykmustthereforereachthevaluen,atwhichtimetheloopisexited,andthevalueofgsatisfiestheoutputspecification.
6.11:
AnannotatedflowchartisshowninFigure6.2.
Figure6.2.AnnotatedflowchartofcodefragmentofProblem6.13.
TheinputspecificationisA:
n∈{1,2,3,…}.Itclearlyholdsatallpointsontheflowchart,andisomittedforsimplicity.TheassertionsatBandCfollowtrivially.
TheloopinvariantD:
m ≤ nandq = 2mholdsthefirsttimetheloopisentered,becausem = 1and21 = 2.AssumethatitholdsatDforsomem = m0.Then,ifm0 ≥ ntheloopterminates,andtheoutputconditionissatisfiedatH.Ifnot,controlpassestoE;asaresultofthefailedconditional,m0 < n.Also,q = 2byhypothesis.
AtF,thevalueofm0hasbeenincreasedby1,andthusm0 ≤ nandq = 2m0 – 1asindicatedontheflowchart.AtG,qhasbeenmultipliedby2.TheassertionatGfollowsfromthefactthat2 ⨯ 2m0 – 1=2m0.
TheassertionatpointGisidenticaltotheassertion,which,byhypothesis,holdsatpointD.ButpointDistopologicallyidenticaltopointG.Byinductionitfollowsthattheloopinvariantholdsforallvaluesofm,1 ≤ m ≤ n.
Allthatremainsistoprovethattheloopterminates.Initiallythevalueofmisequalto0.Eachtimetheloopisiteratedthevalueofmisincreasedby1bythestatementm ← m + 1.Asaconsequenceoftheloopinvariant,mcannotexceedn.Eventuallymmustthereforereachthevaluen,atwhichtimetheloopisexited,andthevalueofqsatisfiestheoutputspecification,thatis,q=2n.
6.12:
Acorrectnessproofismerelyamathematicaldemonstrationthataproductsatisfiesitsspecifications.Thespecificationsmayormaynotreflecttheclient’srealneeds.Thereisnoconnectionbetweentheclient’sneedsandcorrectnessproving.
6.13:
“Correctnessprovingcanbeaveryeffectivewaytoshowboththepresenceandabsenceofbugs,whenusedinconjunctionwithexecution-basedtesting.”
Figure6.3.ExtendedFSMforNaur’stextprocessingproblem.
6.14:
Adesignusinganextendedfinitestatemachine(Section11.6)isgiveninFigure6.3.
States
S0Startingstate—“Waitingforfirstcharacteroffirstwordoffile”
S1“Buildingthefirstword”
S2“Waitingforfirstcharacterofanotherword”
S3“Buildinganotherword”
S4FinalState—“End-of-filecondition”
S5FinalState—“WordlongerthanMAXPOScharactersencountered”
Inputs
NEWLINENewlinecharacter
BLANKBlankcharacter
EOFEndoffileconditionwhenreadattempted
otherAllothercharacters
InitialConditions
Variableline_length,integer,numberofcharactersincurrentoutputline.Initially0.
Variableword,characterstring,wordcurrentlybeingbuilt.Initiallyempty.
Variablec,currentinputcharacter.Noinitialvalue.
ConstantMAXPOS,maximumcharactersinoutputline,excludingNEWLINE.
TransitionsandAssociatedActions
T1WaitingforfirstwordandBLANKorNEWLINEisinput
T2WaitingforfirstwordandEOFisreached
T3Waitingforfirstwordandothercharacterisinput
word←c
T4BuildingfirstwordandBLANKorNEWLINEisinput
write(word)
line_length←length(word)
word←null
T5BuildingfirstwordandEOFisreached
T6Buildingfirst
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- IMSchach8thedChap06v6