《软件测试策略讲义课件.ppt》由会员分享,可在线阅读,更多相关《软件测试策略讲义课件.ppt(40页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、著明软件错误案例研究著明软件错误案例研究讨论v软件测试的重要性?软件测试的重要性?6Software Testing Testing is the process of exercising a program with the specific intent of finding errors prior to delivery to the end user.1 1、测试测试就是就是就是就是实实行具有特定意行具有特定意行具有特定意行具有特定意图计图计划的一个划的一个划的一个划的一个过过程;程;程;程;2 2、测试测试的意的意的意的意图图就是在把就是在把就是在把就是在把软软件件件件产产品交付
2、品交付品交付品交付给给最最最最终终用用用用户户前前前前找出找出找出找出错误错误。测试是有计划有步骤的活动,因此,为测试软件建测试是有计划有步骤的活动,因此,为测试软件建立系统化的立系统化的测试策略测试策略是合情合理的。是合情合理的。717.1 Strategic ApproachvTo perform effective testing,you should conduct effective technical reviews.By doing this,many errors will be eliminated before testing commences.vTesting begi
3、ns at the component level and works outward toward the integration of the entire computer-based system.vDifferent testing techniques are appropriate for different software engineering approaches and at different points in time.vTesting is conducted by the developer of the software and(for large proj
4、ects)an independent test group.vTesting and debugging are different activities,but debugging must be accommodated in any testing strategy.917.1.1V&VvVerification refers to the set of tasks that ensure that software correctly implements a specific function.vValidation refers to a different set of tas
5、ks that ensure that the software that has been built is traceable to customer requirements.Boehm states this another way:Verification:Are we building the product right?Validation:Are we building the right product?v测试是软件质量安全网吗测试是软件质量安全网吗?1117.1.2Who Tests the Software?developerdeveloperindependent te
6、sterindependent testerUnderstands the system Understands the system but,will test gentlybut,will test gentlyand,is driven by deliveryand,is driven by deliveryMust learn about the system,Must learn about the system,but,will attempt to break itbut,will attempt to break itand,is driven by qualityand,is
7、 driven by quality开发者精心地设计和执行测试,试图证明其程序的正确性,而不是注意发现错误。在整个软件项目中,开发人员和(独立)测试组(在整个软件项目中,开发人员和(独立)测试组(ITG)密切配合以确保测试严格)密切配合以确保测试严格地进行。在测试进行的过程中,必须随时可以找到开发人员,以便及时修改发现的地进行。在测试进行的过程中,必须随时可以找到开发人员,以便及时修改发现的错误。错误。讨论和作业v用自己的话描述验证和确认的区别;用自己的话描述验证和确认的区别;v理出一些与独立测试组的创建相关的理出一些与独立测试组的创建相关的问题。问题。ITG和和SQA小组是由相同的人小组是由
8、相同的人员组成的吗?员组成的吗?1317.1.3Testing StrategySystem engineeringAnalysis modelingDesign modelingCode generationUnit testIntegration testValidation testSystem test1417.2 Strategic IssuesvSpecify product requirements in a quantifiable manner long before testing commences.vState testing objectives explicitly
9、.vUnderstand the users of the software and develop a profile for each user category.vDevelop a testing plan that emphasizes“rapid cycle testing.”什么样的指导原则导致成功的软件测试?什么样的指导原则导致成功的软件测试?什么样的指导原则导致成功的软件测试?什么样的指导原则导致成功的软件测试?vBuild“robust”software that is designed to test itselfvUse effective technical revi
10、ews as a filter prior to testingvConduct technical reviews to assess the test strategy and test cases themselves.vDevelop a continuous improvement approach for the testing process.1617.3.1 Unit Testingmodulemoduleto beto betestedtestedtest casestest casesresultsresultssoftwaresoftwareengineerenginee
11、r单元测试侧重于软件设计的最小单元单元测试侧重于软件设计的最小单元(软件构件或模块)的验证工作。(软件构件或模块)的验证工作。17Unit Testinginterface interface local data structureslocal data structuresboundary conditionsboundary conditionsindependent pathsindependent pathserror handling pathserror handling pathsmodulemoduleto beto betestedtestedtest casestest
12、cases测试模块的接口是为了保证被测程序单元的信息能够正常的测试模块的接口是为了保证被测程序单元的信息能够正常的流入和流出;流入和流出;检查局部数据结构以确保临时存储的数据在算法的整个执行检查局部数据结构以确保临时存储的数据在算法的整个执行过程中能维护其完整性。过程中能维护其完整性。测试边界条件以确保模测试边界条件以确保模块在到达边界值的极限块在到达边界值的极限或受限处理的或受限处理的情形下仍能正确执行。情形下仍能正确执行。走遍控制结构中的所有独走遍控制结构中的所有独立路径(基本路径)以确立路径(基本路径)以确保模块中的所有语句至少保模块中的所有语句至少执行一次。执行一次。对所有的错误处理路
13、径进行测试。对所有的错误处理路径进行测试。18Unit Test EnvironmentModuleModulestubstubstubstubdriverdriverRESULTSRESULTSinterface interface local data structureslocal data structuresboundary conditionsboundary conditionsindependent pathsindependent pathserror handling pathserror handling pathstest casestest cases由于构件(模块)
14、并不是独由于构件(模块)并不是独立的程序,因此,必须为立的程序,因此,必须为每个测试单元开发驱动软件每个测试单元开发驱动软件和(或)桩软件和(或)桩软件驱动程序只是一个驱动程序只是一个“主程序主程序”,它接收测试用例数据,将这些数据传递给(将要测试的)构件,它接收测试用例数据,将这些数据传递给(将要测试的)构件并打印相关结果。并打印相关结果。桩程序的作用是替换那些从属于将桩程序的作用是替换那些从属于将要测试的构件或被其调用的构件。要测试的构件或被其调用的构件。当构件具有高内聚时,可简化单元测试。当构件具有高内聚时,可简化单元测试。1917.3.2 Integration Testing Str
15、ategiesOptions:Options:the“big bang”approachthe“big bang”approach an incremental construction strategyan incremental construction strategy集成测试集成测试是构造软件体系结构的系统化技术,同时,也是进行一些旨在发现是构造软件体系结构的系统化技术,同时,也是进行一些旨在发现与接口相关的错误的测试。其目标是利用已通过单元测试的构件建立设计中描述的与接口相关的错误的测试。其目标是利用已通过单元测试的构件建立设计中描述的程序结构。程序结构。“一步到位一步到位”的方式构
16、造程序:所有的构件都事先的方式构造程序:所有的构件都事先连接在一起,全部程序作为一个整体进行测试。连接在一起,全部程序作为一个整体进行测试。增量集成:程序以小增量的方式逐步进行构造增量集成:程序以小增量的方式逐步进行构造和测试,这样错误易于分离和纠正,更易于对和测试,这样错误易于分离和纠正,更易于对接口进行彻底测试,而且可以运用系统化的测接口进行彻底测试,而且可以运用系统化的测试方法。试方法。20Top Down Integrationtop module is tested with top module is tested with stubsstubsstubs are replaced
17、 one at stubs are replaced one at a time,depth firsta time,depth firstas new modules are integrated,as new modules are integrated,some subset of tests is re-runsome subset of tests is re-runA AB BC CD DE EF FGG21Bottom-Up Integrationdrivers are replaced one at a drivers are replaced one at a time,de
18、pth firsttime,depth firstworker modules are grouped into worker modules are grouped into builds and integratedbuilds and integratedA AB BC CD DE EF FGGclustercluster22Regression TestingvRegression testing is the re-execution of some subset of tests that have already been conducted to ensure that cha
19、nges have not propagated unintended side effectsvWhenever software is corrected,some aspect of the software configuration(the program,its documentation,or the data that support it)is changed.vRegression testing helps to ensure that changes(due to testing or for other reasons)do not introduce uninten
20、ded behavior or additional errors.vRegression testing may be conducted manually,by re-executing a subset of all test cases or using automated capture/playback tools.23Smoke TestingvA common approach for creating“daily builds”for product softwarevSmoke testing steps:Software components that have been
21、 translated into code are integrated into a“build.”vA build includes all data files,libraries,reusable modules,and engineered components that are required to implement one or more product functions.A series of tests is designed to expose errors that will keep the build from properly performing its f
22、unction.vThe intent should be to uncover“show stopper”errors that have the highest likelihood of throwing the software project behind schedule.The build is integrated with other builds and the entire product(in its current form)is smoke tested daily.vThe integration approach may be top down or botto
23、m up.2517.4Object-Oriented Testingvbegins by evaluating the correctness and consistency of the analysis and design modelsvtesting strategy changesthe concept of the unit broadens due to encapsulationintegration focuses on classes and their execution across a thread or in the context of a usage scena
24、riovalidation uses conventional black box methodsvtest case design draws on conventional methods,but also encompasses special featuresThese slides are designed to accompany Software Engineering:A Practitioners Approach,7/e(McGraw-Hill 2009).Slides copyright 2009 by Roger Pressman.26Broadening the Vi
25、ew of“Testing”It can be argued that the review of OO analysis and It can be argued that the review of OO analysis and design models is especially useful because the design models is especially useful because the same semantic constructs(e.g.,classes,attributes,same semantic constructs(e.g.,classes,a
26、ttributes,operations,messages)appear at the analysis,operations,messages)appear at the analysis,design,and code level.Therefore,a problem in the design,and code level.Therefore,a problem in the definition of class attributes that is uncovered definition of class attributes that is uncovered during a
27、nalysis will circumvent side effects that during analysis will circumvent side effects that might occur if the problem were not discovered might occur if the problem were not discovered until design or code(or even the next iteration of until design or code(or even the next iteration of analysis).an
28、alysis).OO分析和设计模分析和设计模型的审查特别有用,型的审查特别有用,是因为在分析、设是因为在分析、设计和编码阶段具有计和编码阶段具有相同的语义构图相同的语义构图(例如,类、属性、(例如,类、属性、操作、消息)。所操作、消息)。所以,类属性定义问以,类属性定义问题可以在分析阶段题可以在分析阶段发现,这将避免副发现,这将避免副作用的发生:问题作用的发生:问题直到设计或编码直到设计或编码(或者分析的下一(或者分析的下一次迭代)阶段才发次迭代)阶段才发现现27OO Testing Strategyvclass testing is the equivalent of unit testin
29、goperations within the class are testedthe state behavior of the class is examinedvintegration applied three different strategiesthread-based testingintegrates the set of classes required to respond to one input or eventuse-based testingintegrates the set of classes required to respond to one use ca
30、secluster testingintegrates the set of classes required to demonstrate one collaboration2817.5WebApp Testing-IvThe content model for the WebApp is reviewed to uncover errors.vThe interface model is reviewed to ensure that all use cases can be accommodated.vThe design model for the WebApp is reviewed
31、 to uncover navigation errors.vThe user interface is tested to uncover errors in presentation and/or navigation mechanics.vEach functional component is unit tested.29WebApp Testing-IIvNavigation throughout the architecture is tested.vThe WebApp is implemented in a variety of different environmental
32、configurations and is tested for compatibility with each configuration.vSecurity tests are conducted in an attempt to exploit vulnerabilities in the WebApp or within its environment.vPerformance tests are conducted.vThe WebApp is tested by a controlled and monitored population of end-users.The resul
33、ts of their interaction with the system are evaluated for content and navigation errors,usability concerns,compatibility concerns,and WebApp reliability and performance.31High Order TestingvValidation testingFocus is on software requirementsvSystem testingFocus is on system integrationvAlpha/Beta te
34、stingFocus is on customer usagevRecovery testingforces the software to fail in a variety of ways and verifies that recovery is properly performedvSecurity testingverifies that protection mechanisms built into a system will,in fact,protect it from improper penetrationvStress testing executes a system
35、 in a manner that demands resources in abnormal quantity,frequency,or volumevPerformance Testingtest the run-time performance of software within the context of an integrated system3217.8Debugging:A Diagnostic Process调试并不是测试,但总是发生在测试之后。调试并不是测试,但总是发生在测试之后。调试试图将症状(调试试图将症状(symptomsymptom)与原因相匹配,从而使错误得到修
36、正)与原因相匹配,从而使错误得到修正)与原因相匹配,从而使错误得到修正)与原因相匹配,从而使错误得到修正 。33The Debugging Process34Debugging Efforttime requiredtime requiredto diagnose theto diagnose thesymptom andsymptom anddetermine thedetermine thecausecausetime requiredtime requiredto correct the errorto correct the errorand conductand conductreg
37、ression testsregression tests35Symptoms&Causessymptomsymptomcausecausesymptom and cause may be symptom and cause may be geographically separated geographically separated symptom may disappear when symptom may disappear when another problem is fixedanother problem is fixedcause may be due to a cause
38、may be due to a combination of non-errors combination of non-errors cause may be due to a system cause may be due to a system or compiler erroror compiler errorcause may be due to cause may be due to assumptions that everyone assumptions that everyone believesbelievessymptom may be intermittentsympt
39、om may be intermittent为什么调试如此困难?为什么调试如此困难?36Consequences of BugsdamagemildannoyingdisturbingseriousextremecatastrophicinfectiousBug TypeBug Categories:Bug Categories:function-related bugs,function-related bugs,system-related bugs,data bugs,coding bugs,system-related bugs,data bugs,coding bugs,design
40、 bugs,documentation bugs,standards design bugs,documentation bugs,standards violations,etc.violations,etc.37Debugging Techniquesbrute force/testingbacktrackinginductiondeduction蛮力调试法:利用蛮力调试法:利用“让计算机自己找错误让计算机自己找错误”的思想。最常用但最低效的方法。的思想。最常用但最低效的方法。回溯法:从发现症状的地方开始,向后追踪(手工)源代码,直到发现错误的原因。回溯法:从发现症状的地方开始,向后追踪(
41、手工)源代码,直到发现错误的原因。原因排除法:通过演绎(原因排除法:通过演绎(deduction)或归纳(或归纳(induction)并引入二分法的概念来并引入二分法的概念来实现。实现。38Correcting the ErrorvIs the cause of the bug reproduced in another part of the program?In many situations,a program defect is caused by an erroneous pattern of logic that may be reproduced elsewhere.vWhat
42、next bug might be introduced by the fix Im about to make?Before the correction is made,the source code(or,better,the design)should be evaluated to assess coupling of logic and data structures.vWhat could we have done to prevent this bug in the first place?This question is the first step toward estab
43、lishing a statistical software quality assurance approach.If you correct the process as well as the product,the bug will be removed from the current program and may be eliminated from all future programs.39Final ThoughtsvThink-before you act to correctvUse tools to gain additional insightvIf youre at an impasse,get help from someone elsevOnce you correct the bug,use regression testing to uncover any side effectsv项目进度安排是如何影响集成测试的?v谁应该完成集成测试,是软件开发人员还是软件使用者,说明你的理由。v17.10
限制150内