The object oriented process of testing, is gaining popularity because it is having benefits in analysis, design and coding. Conventional methods of testing which can’t be applied for testing classes due to problems involved in testing classes, abstract classes, inheritance, dynamic-binding, message passing, polymorphism, concurrency. Testing the classes may be different than testing the functions. A function has a clear input-output behaviour, while a class does not have an input-output specification. We can also test method of a class using the approaches for testing functions and we cannot test the class using these approaches.
The dependencies occurring in conventional systems are:
- Data dependencies between variables.
- Calling dependencies between modules
- Functional dependencies between a module and the variable it calculates.
- Definitional dependencies between a variable and its types.
In object oriented programs control flow is characterised by the message passing among all the objects, and therefore the control flow switches from one object to other, inter-object communication. We have no control flow within a class functions. The lack of sequential control flow within a class requires different approaches for testing. In object the state associated with the object also influences the path of execution and methods of a class which can communicate among themselves while this state is persistent across invocations of the method.
Techniques of Object oriented programming are:
- Fault based testing- This sort of testing verifies and permits for coming up with a test cases supported the consumer specification or code or both. It always tries to identify the possible faults and for all these faults a test case will be developed to “flush” the errors. This procedure does find the all types of errors. Anyhow incorrect specification and interface errors which will be missed. These type of errors can be uncovered by the function testing in any traditional testing model. In object oriented model, interaction errors will be uncovered by scenario-based testing.This form of object oriented testing which can be tested against the client’s specification .
- Class Testing based on the method testing- This is the simplest approach to test classes. Each method of class performs a well defined cohesive function and can therefore be related to unit testing of the traditional testing techniques, so the methods can be involved at least once to test the class.
- Random testing- It is supported by developing a random test sequence which tries the minimum variety of operations typical to the behaviour of the categories.
- Partition testing- This methodology divides the inputs and outputs of different category so as to check them severely. This will minimise the number of cases that have to be designed.
How it will work?
It works based on three strategies:
- Looking for base classes.
- By designing Test suite for each Base class for each method
- Testing the history associates each test case with the attribute it’s testing.
- Subclass test history will be derived from parents test history.
- Child test history is incrementally is updated to revert differences from the parent.
- The test history which understands which tests to execute for subclasses inherited attributes are retested. Attributes which require new test cases and also can be identified easily.