UnitTestConceptCoverageTool

上传人:仙*** 文档编号:243972170 上传时间:2024-10-01 格式:PPT 页数:19 大小:1.23MB
返回 下载 相关 举报
UnitTestConceptCoverageTool_第1页
第1页 / 共19页
UnitTestConceptCoverageTool_第2页
第2页 / 共19页
UnitTestConceptCoverageTool_第3页
第3页 / 共19页
点击查看更多>>
资源描述
Click to edit Master title style,Click to edit Master text styles,Second level,Third level,Fourth level,Fifth level,Click to edit Master title style,Click to edit Master text styles,Second level,Third level,Fourth level,Fifth level,C O N F I D E N T I A L,Apr-17-08,Unit Test,Concept&Coverage&Tool,Presented by,Tao,April 2008,C O N F I D E N T I A L,Aug-10-07,Sections,Introduction to Unit Testing,Code Test Coverage with CoberTura,Q&A,Resources,I.Introduction to Unit Testing,Introduction to automated unit tests,C O N F I D E N T I A L,Aug-10-07,C O N F I D E N T I A L,Aug-10-07,Introduction to automated unit tests,Testing is the less glamorous part of software development,“Testing is the ugly step-child of software development”,eXtreme Programming eXplained,Kent Beck,Addison-Wesley,2000,The dilemma of developer testing:,Everyone knows that testing is important.,Everyone knows they dont do enough testing.,Manual testing is:,Tedious high level of detail and discipline required,Error-prone easy to forget to run a test or run it incorrectly not repeatable,Time intensive often testing is done at the end of a project,close to delivery.When time gets tight,it is difficult to do enough testing,Cost to the project,“The earlier the defects or bugs are found,the lower the cost to the project”,Code Complete,second edition,Steve McConnell,Microsoft Press,2004,Automated Unit Testing addresses these issues,C O N F I D E N T I A L,Aug-10-07,Unit Test Who and when,Unit Tests are written by the developers,The developer who creates an Object is the most familiar with that Object and is in the best position to know how to test it correctly.,Unit Tests are best written for an Object,Before methods are written,Writing tests first often helps to define a good interface.,As methods are written,Implementation could be complicated and require extra testing.,After methods are written,Its impossible to think of everything.Add new tests not previously thought of.,When new bugs are found,When a bug is discovered,write a test to expose it and prove it is fixed.,C O N F I D E N T I A L,Aug-10-07,Unit Test Who runs and when,Unit Tests are run by the developers and Release/SCM,Developers run the unit tests often.,Ensuring changes made work correctly and dont mysteriously break the code elsewhere.,Single unit tests or small suites of tests after making changes.,All tests for a module as part of the module release.,Release/SCM team runs the unit tests as part of the automated build process:,Ensuring the system is in a stable,working state and is ready for feature testing.,C O N F I D E N T I A L,Aug-10-07,II.Code Test Coverage with CoberTura,What is unit test coverage,Line Coverage vs.Branch Coverage vs.Complexity,Coverage vs.Effort vs.Failures,Why CoberTura,CoberTura Usage,Example CoberTura Report,C O N F I D E N T I A L,Aug-10-07,What is unit test coverage,Unit test coverage defines how thorough your unit tests are,All conditions are tested for(if/else,try/catch,case/switch,etc.),How many times branches of code are run through,Establishes confidence,High%coverage means less chance for regression,Allows refactoring without fear,Shows quality of unit tests,High quality unit tests have high coverage(Not true versus,high coverage does not mean high quality necessarily,need more practices to increase the code quality but high coverage is the starting point.),Shows how useful unit tests are for documenting the usage of code for peer training,C O N F I D E N T I A L,Aug-10-07,Line Coverage vs.Branch Coverage vs.Complexity,Line Coverage,Indicates if each executable statement is encountered in test cases,Does not indicate if conditions(if/else,try/catch,loop termination)are covered.,Branch Coverage,Indicates whether conditions are executed in test cases,Does not indicate if early terminating condition(e.g.OR statements)are properly covered.,Code Complexity,Also known as McCabes cyclomatic code complexity algorithm,Determines how complex a section of code is,The higher the complexity number the more unit test coverage is required,Measured by counting the number of paths there are through a section of code and comparing against an ordinal number(1).,C O N F I D E N T I A L,Aug-10-07,Coverage vs.Effort vs.Failures,Increasing test coverage reaches a point of diminishing returns,100%line/branch coverage is impossible,90%is very time consuming but reduces failures,60-80%about where testing,failures and effort are all close to ideal,Figure taken from,http:/,C O N F I D E N T I A L,Aug-10-07,McCabes Code Complexity,How to interpret McCabes code complexity,StarCite should try to keep code complexity below 15,Refactor existing code to get to this level of complexity,Code complexity above 15 is too hard to test,MKV and MV has some code in the 20s all areas with high bug counts or instability,McCabes code complexity directly corresponds with the bugginess,stability and testability of software,Software refactored for testability=less buggy and more stable,Complexit
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 管理文书 > 施工组织


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!