Improving the testability of object oriented software through software contracts

Software testing is one of the most expensive phases of the software development life cycle. Testing object oriented software is more expensive due to various features like abstraction, inheritance etc. The cost of testing can be reduced by improving the software testability. Software testability of a class is generally measured in terms of the testing effort which is equal to the number of test cases required to test a class. Hence testability can be improved if the test cases can be reduced. Software contracts (method preconditions, method postcondtions, and class invariant) can be used in improving the testability of the software. This paper demonstartes how software contracts can be used to reduce the number of test cases and hence improve the testability of an object oriented software. To accomplish this, software contracts are instrumented in a class and test cases are designed for this class using the path testing technique and then it is compared with the class without instrumenting the software contracts. We found that the instrumentation of software contracts reduces the number of test cases and hence improves the testability.