utility of test coverage metrics in tdd
TRANSCRIPT
![Page 2: Utility of Test Coverage Metrics in TDD](https://reader036.vdocument.in/reader036/viewer/2022083104/588221201a28ab3f4c8b7c11/html5/thumbnails/2.jpg)
Learning Objectives
• TDD Overview• Common Test Coverage Metrics• Significance of Test Coverage Metrics in TDD• Test Coverage Measurement Tools
![Page 3: Utility of Test Coverage Metrics in TDD](https://reader036.vdocument.in/reader036/viewer/2022083104/588221201a28ab3f4c8b7c11/html5/thumbnails/3.jpg)
TDD
• Software development technique in which tests are written prior to code
• If you can’t write test for what you are trying to code, then you should not be thinking about coding
• TDD reduces the gap between design and feedback (performance achieved by implementing the design)
![Page 4: Utility of Test Coverage Metrics in TDD](https://reader036.vdocument.in/reader036/viewer/2022083104/588221201a28ab3f4c8b7c11/html5/thumbnails/4.jpg)
Test Coverage Metrics
• Statement Coverage• Branch Coverage• Condition Coverage• MCDC• Data Flow Coverage• Path Coverage• Mutation Coverage
![Page 5: Utility of Test Coverage Metrics in TDD](https://reader036.vdocument.in/reader036/viewer/2022083104/588221201a28ab3f4c8b7c11/html5/thumbnails/5.jpg)
Mutation Coverage
• Mutation – small change in program• Apply mutations to program to obtain set of
mutants M1, M2 … Mn• Run test suite on each of mutants. Mutant is
killed if an error is detected• Mutation Test Coverage = No. of mutants killed /
Total no. of mutants• Has to be automated for any reasonable sized
program
![Page 6: Utility of Test Coverage Metrics in TDD](https://reader036.vdocument.in/reader036/viewer/2022083104/588221201a28ab3f4c8b7c11/html5/thumbnails/6.jpg)
Mutation Coverage
• May not be practical to consider all possible mutants
• Use mutation operators (rules) to generate mutants
• Value mutations – change values to reflect errors in reasoning about programs
• Decision mutations – change relational operators or parenthesisation in conditions
• Statement mutations – change whole line of code
![Page 7: Utility of Test Coverage Metrics in TDD](https://reader036.vdocument.in/reader036/viewer/2022083104/588221201a28ab3f4c8b7c11/html5/thumbnails/7.jpg)
Test Coverage Measurement Tools
• PIT (www.pitest.org)• Jumble (http://jumble.sourceforge.net/)• Clover
(https://www.atlassian.com/software/clover/overview)
• Cobertura (http://cobertura.github.io/cobertura/)
• EMMA (http://emma.sourceforge.net/)
![Page 8: Utility of Test Coverage Metrics in TDD](https://reader036.vdocument.in/reader036/viewer/2022083104/588221201a28ab3f4c8b7c11/html5/thumbnails/8.jpg)
PIT
• Measures line coverage and mutation coverage• Bytecode based mutant generation• Test selection is automatic – based on line
coverage• Can be integrated with Ant or Maven based
build systems• Compatible with most mocking frameworks,
except Powermock and Jmockit
![Page 9: Utility of Test Coverage Metrics in TDD](https://reader036.vdocument.in/reader036/viewer/2022083104/588221201a28ab3f4c8b7c11/html5/thumbnails/9.jpg)
Observations
• TDD does not imply that the tests are perfect• Test Coverage measurements are relevant to
TDD• Mutation coverage tells whether something is
really tested• Tools are available which make it practical to
measure mutation coverage
![Page 10: Utility of Test Coverage Metrics in TDD](https://reader036.vdocument.in/reader036/viewer/2022083104/588221201a28ab3f4c8b7c11/html5/thumbnails/10.jpg)
Future Work
• Collect more data on test coverage in TDD• Effectiveness of mutation coverage vs. other
coverage metrics• Comparison between various coverage
measurement tools• Study effect of mocking frameworks on code
coverage