您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > 软件测试ST02_Graph_Coverage
软件测试与质量保证魏培阳weipy@cuit.edu.cn申明:本课件是在原书作者课件基础上编制,仅用于课堂教学,不得用于任何商业目的的活动。1PaulAmmann&JeffOffuttGRAPHCOVERAGEChapter22PaulAmmann&JeffOffutt图覆盖第2章3OUTLINEOverGraphicCoverageCriteriaGraphCoverageforSourceCodeGraphCvoerageforDesignElementsGraphCoverageforSpecificationsGraphCoverageforUseCaseRepresentingGraphsAlgebraically4大纲图覆盖概述源代码的图覆盖设计元素的图覆盖规格说明的图覆盖用例的图覆盖用代数方法表示图5CH.2:GRAPHCOVERAGEFourStructuresforModelingSoftwareGraphsLogicInputSpaceSyntaxUsecasesSpecsDesignSourceAppliedtoDNFSpecsFSMsSourceAppliedtoInputModelsIntegSourceAppliedto6第二章:图覆盖软件建模的四种结构图逻辑表达式输入域语法用例规格设计源程序应用于析取范式规格有限状态机源程序应用于输入模型集成源程序应用于7COVERINGGRAPHS(2.1)•Graphsarethemostcommonlyusedstructurefortesting•Graphscancomefrommanysources•Controlflowgraphs•Designstructure•FSMsandstatecharts•Usecases•Testsusuallyareintendedto“cover”thegraphinsomeway8覆盖图S(2.1)•图形是测试中最常用的结构•图形有多种来源•控制流图•设计结构•有限状态机和状态图•用例•测试通常是为了以某种方式“覆盖”图9DEFINITIONOFAGRAPH•AsetNofnodes,Nisnotempty•AsetN0ofinitialnodes,N0isnotempty•AsetNfoffinalnodes,Nfisnotempty•AsetEofedges,eachedgefromonenodetoanother•(ni,nj),iispredecessor,jissuccessor10定义一个图•节点的集合N,N不为空•初始节点的集合N0,N0不为空•终止节点的集合Nf,Nf不为空•边的集合E,每条边从一节点到另一个节点•(ni,nj),i是前驱节点,j是后续节点11THREEEXAMPLEGRAPHS0213N0={0}Nf={3}0213N0={}Nf={3}9043715826N0={0,1,2}Nf={7,8,9}Notavalidgraph12三个示例图0213N0={0}Nf={3}0213N0={}Nf={3}9043715826N0={0,1,2}Nf={7,8,9}不是一个有效图13PATHSINGRAPHS•Path:Asequenceofnodes–[n1,n2,…,nM]•Eachpairofnodesisanedge•Length:Thenumberofedges•Asinglenodeisapathoflength0•Subpath:Asubsequenceofnodesinpisasubpathofp•Reach(n):Subgraphthatcanbereachedfromn9780124356AFewPaths[0,3,7][1,4,8,5,1][2,6,9]Reach(0)={0,3,4,7,8,5,1,9}Reach({0,2})=GReach([2,6])={2,6,9}14图中的路径•路径:一个节点序列[n1,n2,…,nM]•每对节点是一条边•长度:边的数量•单个节点是路径为0的边•子路径:路径p的子路径是p的一个子节点序列•可达性Reach(n):能够从n到达的子图9780124356一些路径[0,3,7][1,4,8,5,1][2,6,9]Reach(0)={0,3,4,7,8,5,1,9}Reach({0,2})=GReach([2,6])={2,6,9}15TESTPATHSANDSESES•TestPath:Apaththatstartsataninitialnodeandendsatafinalnode•Testpathsrepresentexecutionoftestcases•Sometestpathscanbeexecutedbymanytests•Sometestpathscannotbeexecutedbyanytests•SESEgraphs:Alltestpathsstartatasinglenodeandendatanothernode•Single-entry,single-exit•N0andNfhaveexactlyonenode0216354Double-diamondgraphFourtestpaths[0,1,3,4,6][0,1,3,5,6][0,2,3,4,6][0,2,3,5,6]16测试路径和单入/单出图•测试路径:起始于初始节点并且终止于终点的一条路径•测试路径代表了一个测试用例的执行•一些测试路径可以执行许多测试????????????????????????????•一些测试路径不能执行任何测试????????????????????????????•单入/单出图:所有的测试路径均开始于一个节点并终止于一个单一节点•单入(Single-entry),单出(single-exit)•N0和Nf分别有且仅有一个节点0216354测试路径的双夌图[0,1,3,4,6][0,1,3,5,6][0,2,3,4,6][0,2,3,5,6]17VISITINGANDTOURING•Visit:AtestpathpvisitsnodenifnisinpAtestpathpvisitsedgeeifeisinp•Tour:AtestpathptourssubpathqifqisasubpathofpPath[0,1,3,4,6]Visitsnodes0,1,3,4,6Visitsedges(0,1),(1,3),(3,4),(4,6)Tourssubpaths[0,1,3],[1,3,4],[3,4,6],[0,1,3,4],[1,3,4,6]18访问和游历•访问:如果节点n在测试路径p中,则这条测试路径访问了节点n一个测试路径p访问边e,如果e在p上•游历:一个测试路径p游历子路径问q,如果q是p的一个子路径路径[0,1,3,4,6]访问节点0,1,3,4,6访问边(0,1),(1,3),(3,4),(4,6)游历子路径[0,1,3],[1,3,4],[3,4,6],[0,1,3,4],[1,3,4,6]19TESTSANDTESTPATHS•path(t):Thetestpathexecutedbytestt•path(T):ThesetoftestpathsexecutedbythesetoftestsT•Eachtestexecutesoneandonlyonetestpath•Alocationinagraph(nodeoredge)canbereachedfromanotherlocationifthereisasequenceofedgesfromthefirstlocationtothesecond•Syntacticreach:Asubpathexistsinthegraph•Semanticreach:Atestexiststhatcanexecutethatsubpath20测试和测试路径•映射path(t):被测试用例t执行的测试路径•映射path(T):被测试集合T执行的测试集合•每个测试执行且仅执行一个测试路径•从其他位置到图上的某个位置(节点或边)可达,如果从边缘位置到其后存在一个边的序列。•语法可达:图中存在一条子路径•语义可达:存在能被子路径执行的测试21TESTSANDTESTPATHStest1test2test3many-to-onetest1test2test3many-to-manyTestPath1TestPath2TestPath3Non-deterministicsoftware–atestcanexecutedifferenttestpathsTestPathDeterministicsoftware–atestalwaysexecutesthesametestpath22测试和测试路径test1test2test3多对一test1test2test3多对鑫TestPath1TestPath2TestPath3不确定的软件——一个测试执行不同的测试路径TestPath确定性软件——一个测试总是执行相同的测试路径23TESTINGANDCOVERINGGRAPHS(2.2)•Weusegraphsintestingasfollows:•Developingamodelofthesoftwareasagraph•Requiringteststovisitortourspecificsetsofnodes,edgesorsubpaths•TestRequirements(TR):Describepropertiesoftestpaths•TestCriterion:Rulesthatdefinetestrequirements•Satisfaction:GivenasetTRoftestrequirementsforacriterionC,asetoftestsTsatisfiesConagraphifandonlyifforeverytestrequirementinTR,thereisatestpathinpath(T)thatmeetsthetestrequirementtr•StructuralCoverageCriteria:Definedonagraphjustintermsofnodesandedges•DataFlowCoverageCriteria:Requiresagraphtobeannotatedwithreferencestovariables24测试的图覆盖(2.2)•我们使用图表测试如下:•开发图一样的软件模型•需求测试来访问或游历特定的节点集,边或子路径•测试需求(TR):描述属性的测试路径•测试标准:定义测试需求的规则•满足:对标准C给定一组测试需求TR,在图中测试集合T满足标准C,当且仅当每个TR中的测试需求tr,在path(T)中存在一个测试路径经过测试需求tr•结构覆盖标准:只是从节点和边定义一个图•数据流覆盖标准:需要用引用变量标注一个图25NODEANDEDGECOVERAGE•Thefirst(andsimplest)twocriteriarequirethateachnodeandedgeinagraphbeexecutedNodeCoverage(NC):TestsetTsatisfiesnodecoverageongraphGiffforeverysyntacticallyreachablenodeninN,thereissomepathpinpath(T)suchthatpvisitsn.NodeCoverage(NC):TRcontainseachreachablenodeinG.•Thisstatementisabitcumbersome,soweabbreviateitintermsofthesetoftestrequirements26节点和边覆盖•第一个(也是最简单的)两个标准要求图中每个节点和边被
本文标题:软件测试ST02_Graph_Coverage
链接地址:https://www.777doc.com/doc-1992127 .html