? UT Overview ? Google Test ? Google Mock ? Resource ? Summary ? UT Concept ? UT Tools Overview ? swebok 2004: Unit testing verifies the functioning in isolation of software pieces which are separately testable. Depending on the context, these could be the individual subprograms or a ponent made of tightly related units. ”?“ module testing (or unit testing) is a process of testing the individual subprograms, subroutines, or procedures in a program. that is, rather than initially testing the program as a whole, testing is first focused on the smaller building blocks of the program. ”---《 the art of software testing (2nd) ?《统一软件开发过程》中也对单元测试进行了描述( p223 ): “执行单元测试的目的是为了把已实现的构件作为个体单元进行测试,主要有以下几类单元测试: 规格说明测试( specification testing )或“黑盒测试”,验证单元外观上的可观察的行为; 结构测试( structure testing )或“白盒测试”,验证单元的内部实现”“构件是模型元素(如设计模型中的设计类)的物理包”,可见,根据这样的描述,将一个类或是一段代码片断作为单元测试的目标绝对是 rup 所认可的。? Goal : ? check the unit bug(interface/data/logic/coverage/boundary/ variable ) & fix ? Optimizations ? Restructuring for better design ? when: ? After coding ? Role:R&D ? Stub & Mock ? Coverage: 1、语句覆盖?选择足够的测试用例,使得程序中每一条可执行语句至少被执行一次。 2、判定覆盖?选择足够的测试用例,使得程序中每一个分支判断的每一种可能结果(主要指 switch- case 情况)都至少被执行一次。判定覆盖也叫分支覆盖。 3、条件覆盖?选择足够的测试用例,使得程序中每一个分支判断中的每一个条件的可能结果都至少被执行一次。 4、其他: 判定/条件覆盖、组合覆盖、路径覆盖? CPPunit ? Google test framework ? Junit ? Visual unit ? What ? Why ? How ? A library for writing C++ tests ? Open-source with new BSD license ? Based on xUnit architecture ? Supports Linux, Windows , Mac OS, and other OSes ? Can generate JUnit-style XML, parsable by Hudson ? Portable ? Easy to learn yet expressive ? Rich features ? Add debug info to assertions using << ? Death tests ? User-defined predicate assertions ? Value/type-parameterized tests ? Test event listener API (user-defined plug-ins) ? Test filtering ? Test shuffling ? Actively supported Talk to googletestframework@ for questions or feature requests. ? offical website : http://code./p/googletest/ ? Latest version: ? Msvc dir
google test 单元测试 来自淘豆网www.taodocs.com转载请标明出处.