Reliable Objects: Lightweight Testing for OO Languages

Download Report

Transcript Reliable Objects: Lightweight Testing for OO Languages

Reliable Objects:
Lightweight Testing for OO Languages
David Mattingly
Problems addressed
Based on waterfall model – not on
iterative models.
 No longer feasible to separate
testing from specification, design,
coding.
 Not based upon inherent power of
OO.

Specifying behavior
Must know what each component
should do in every situation
 No formal specification language

Design by Contract
Lightweight descriptions
 Captures mutual obligations and
benefits
 Must specify every consistency
condition
 Boolean assertions

Implementation
Implementations exist in Eiffel, Java,
C++, Perl.
 Eiffel only language to directly
support design by contract.
 All other languages rely on outside
utilities.

Java Implementation
Example from Pylon library
(www.nenie.org/eiffel/pylon)
 Source code with self-testable
classes at www.iuvannes.fr/docinfo/stclass

Java Design by Contract
Contract Watchdogs
 trace and assert

Implementation 1
Call inherited functions directly in
code.
 Another level of inheritance.
 Calls inside methods can be
forgotten about.

Implementation 2
Contract definition in comments
 Preprocessor
 iContract (www.reliablesystems.com/tools)

Making self-testable classes
Define pre and post-conditions in
comments.
 Interface inheritance and
Delegation.
 Testing methods: testing unit & goal

Validation & Verification
Compile with iContract & Java
compiler.
 Output details results of tests.

Abstract Classes
Cannot be self-testable
 Can define contracts
 Implementing classes inherit
contracts

Mutation Testing
Determine how adequate our tests
our.
 Adequate Test set distinguishes the
original program from mutants.
