Object Oriented Testing and Test-Driven Development
Object Oriented Testing and Test-Driven Development
([email protected])
Larman, chapter 21 and notes on Larman from George Blank of NJIT plus Glenn Blanks elaborations and expansions
Objectives
To discuss when testing takes place in the life cycle
analysis design
code
test
To cover the strategies and tools associated with object oriented testing
Analysis and Design Testing Class Tests Integration Tests Validation Tests System Tests
Object-Oriented Testing
When should testing begin? Analysis and Design:
Testing begins by evaluating the OOA and OOD models How do we test OOA models (requirements and use cases)? How do we test OOD models (class and sequence diagrams)? Structured walk-throughs, prototypes Formal reviews of correctness, completeness and consistency
Programming:
How does OO make testing different from procedural programming? Concept of a unit broadens due to class encapsulation Integration focuses on classes and their context of a use case scenario or their execution across a thread Validation may still use conventional black box methods
Test-driven programming
eXtreme Programming (XP) advocates writing tests for units before writing actual code for units Why might this practice be a good idea? Constrains code to design: How so?
Design -> Test -> Code in small iterations
YAHOO!
Strategic Issues
Issues for a successful software testing strategy:
Specify product requirements long before testing commences For example: portability, maintainability, usability Do so in a manner that is unambiguous and quantifiable Understand the users of the software, with use cases Develop a testing plan that emphasizes rapid cycle testing Get quick feedback from a series of small incremental tests Build robust software that is designed to test itself Use assertions, exception handling and automated testing tools (Junit). Conduct formal technical reviews to assess test strategy and test cases - Who watches the watchers?
Semantic correctness:
Does the model reflect the real world problem? Is UML used as intended by its designers?
Is the ADT design complete (capturing all the classes and operations in UML diagram) and understandable?
2. Invert connections to ensure that each collaborator asked for a service is receiving requests from a reasonable source
Example: a credit card being asked for a purchase amount
Testing OO Code
Class tests
Integration tests
System tests
Validation tests
Can we do better?
Testing Summary
Testing affects all stages of software engineering cycle One strategy is a bottom-up approach class, integration, validation and system level testing XP advocates test-driven development: plan tests before you write any code, then test any changes
Other techniques:
white box (look into technical internal details) black box (view the external behaviour) debugging (systematic cause elimination approach is best)
analysis design code test