A number of activities involved in testing software are known to be difficult and time consuming. Among them is the definition and coding of test oracles and the isolation of faults once failures have been detected. Through a thorough and rigorous empirical study, we investigate how the instrumentation of contracts could address both issues. Contracts are known to be a useful technique in specifying the precondition and postcondition of operations and class invariants, thus making the definition of object-oriented analysis or design elements more precise. It is one of the reasons the Object Constraint Language (OCL) was made part of the Unified Modeling Language. Our aim in this paper is to reuse and instrument contracts to ease testing. A thorough case study is run where we define OCL contracts, instrument them using a commercial tool and assess the benefits and limitations of doing so to support the automated detection of failures and the isolation of faults. As contracts can be defined at various levels of detail, we also investigate the cost and benefit of using contracts at different levels of precision. We then draw practical conclusions regarding the applicability of the approach and its limitations. Copyright

Additional Metadata
Keywords Contracts, Object-oriented analysis, Object-oriented testing, Testability
Persistent URL dx.doi.org/10.1002/spe.520
Journal Software - Practice and Experience
Briand, L.C., Labiche, Y, & Sun, H. (2003). Investigating the use of analysis contracts to improve the testability of object-oriented code. Software - Practice and Experience, 33(7), 637–672. doi:10.1002/spe.520