Traditional vs. Object-Oriented Approaches

Object-oriented approaches to software development are an important expansion of procedural approaches. Java explicitly supports both approaches, but you should focus on the object-oriented approach. This article compares the two approaches and explains the fundamentals of each.

4. Object-Oriented Approach

4.3. Object-Oriented Approach: Testing

Testing is an activity to verify that a correct system is being built. Testing is traditionally an expensive activity, primarily because many faults are not detected until late in the development. To do effective testing we must have as a goal that every test should detect a fault.

Unit testing is performed to test a specific unit, where a unit can be of varying size from a class up to an entire subsystem. The unit is initially tested structurally, that is, "white box testing." This means that we use our knowledge of the inside of the unit to test it. We have various coverage criteria for the test, the minimum being to cover all statements. However, coverage criteria can be hard to define, due to polymorphism; many branches are made implicit in an object-oriented system. However, polymorphism also enhances the independence of each object, making them easier to test as standalone units. The use of inheritance also complicates testing, since we may need to retest operations at different levels in the inheritance hierarchy. On the other hand, since we typically have less code, there is less to test. Specification testing of a unit is done primarily from the object protocol (so-called "black box testing). Here we use equivalence partitioning to find appropriate test cases. Test planning must be done early, along with the identification and specification of tests [2].