Object Oriented Testing Techniques: Survey and Challenges
Total Page:16
File Type:pdf, Size:1020Kb
ISSN:2229-6093 Prashant ,Int.J.Computer Technology & Applications,Vol 3 (2), 746-749 Object Oriented Testing Techniques: Survey and Challenges Prashant, Dept. Of I.T., Gurgaon College of Engg., Gurgaon, Haryana. [email protected] Abstract: Object-oriented programs involve many unique excellent structuring mechanism. They allow a features that are not present in their conventional system to be divided into well-defined units, which counterparts. Examples are message passing, may then be implemented separately. Second, classes synchronization, dynamic binding, object instantiation, support information hiding. Third, object-orientation persistence, encapsulation, inheritance, and polymorphism. encourages and supports software reuse. This may be Testing for such program is, therefore, more difficult than that for conventional programs. Object-orientation has achieved either through the simple reuse of a class in rapidly become accepted as the preferred paradigm for a library, or via inheritance, whereby a new class may large-scale system design. In this paper we have discussed be created as an extension of an existing one [2]. about how testing is being carried out in the Object These might cause some types of faults that are Oriented environment. To accommodate this, several new difficult to detect using traditional testing techniques. techniques have been proposed like fault-based techniques, To overcome these deficiencies, it is necessary to Scenario based, Surface structure testing, and Deep adopt an object-oriented testing technique that takes structural testing. these features into account. Keywords-Fault-based Testing, Scenario-based Testing, 2. TROUBLE MAKERS OF OBJECT ORIENTED Surface Structure Testing. SOFTWARE 1. INTRODUCTION Following are trouble makers of OO Software The testing of software is an important means of 2.1 Encapsulation A wrapping up of data and assessing the software to determine its Quality. With functions into a single unit is known as the development of Fourth generation languages encapsulation. This restricts visibility of object states (4GL), which speeds up the implementation process, and also restricts observability of intermediate test the proportion of time devoted to testing increased. results. Fault discovery is more difficult in this case. As the amount of maintenance and upgrade of 2.2 Polymorphism Polymorphism is one of the existing systems grow, significant amount of testing crucial features of OOP. It simply means one name will also be needed to verify systems after changes multiple forms. Because of polymorphism, all are made [1]. Most testing techniques were originally possible bindings have to be tested. All potential developed for the imperative programming paradigm, execution paths and potential errors have to be tested. with relative less consideration to object-oriented 2.3 Inheritance The mechanism of deriving a new features such as message passing, synchronization, class from an old one is called inheritance. The old dynamic binding, object instantiation, persistence, class is referred to as the base class and the new one encapsulation, inheritance, and polymorphism. is called the derived class or the subclass. Inheritance Objects may interact with one another with results in invisible dependencies between unforeseen combinations and invocations. The testing super/sub-classes. Inheritance results in reduced code of concurrent object-oriented systems has become a redundancy, which results in increased code most challenging task. Object-orientation has rapidly dependencies. If the function is erroneous in the base become accepted as the preferred paradigm for large class, it will be inherited in the derived class too. A scale system design. The reasons for this are well subclass can’t be tested without its super classes. known and understood. First, classes provide an 746 ISSN:2229-6093 Prashant ,Int.J.Computer Technology & Applications,Vol 3 (2), 746-749 3. THE TEST MODEL AND ITS CAPABILITIES Test the state behavior (attributes) of the The tools for automated testing are based upon class between methods certain models of software/programs and algorithms. Class testing is different from conventional testing in This mathematically defined test model consists of that Conventional testing focuses on following types of diagrams: input-process-output, whereas class testing focuses on each method. 3.1 Class Diagram: A class diagram or an object Test cases should be designed so that they are relation diagram (ORD) represents the relationships explicitly associated with the class and/or method to between the various classes and its type. Types of be tested. The purpose of the test should be clearly relationships are mainly: inheritance, aggregation, stated. Each test case should contain: and association. In object oriented programs there are three different relationships between classes they are A list of messages and operations that will inheritance, aggregation and association. be exercised as a consequence of the test A list of exceptions that may occur as the 3.2 Control Flow Graph: A control flow graph object is tested represents the control structure of a member function A list of external conditions for setup (i.e., and its interface to other member functions so that a changes in the environment external to the tester will know which is used and/or updated and software that must exist in order to properly which other functions are invoked by the member conduct the test) function. Supplementary information that will aid in 3.3 State Transition Diagram: A STD or an Object understanding or implementing the test State Diagram (OSD) represents the state behavior of Since object oriented software is rich in an object class. Now the state of a class is embodied encapsulation, Inheritance and Polymorphism the in its member variables which are shared among its following challenges are faced while performing methods. The OSD shows the various states of a class class testing. (various member variable values), and transitions It is difficult to obtain a snapshot of a class between them (method invocations). without building extra methods that display 4 . OBJECT ORIENTED TESTING TECHNIQUES the classes’ state. Each new context of use (subclass) requires Object – Oriented programming is centered around re-testing because a method may be concepts like Object, Class, Message, Interfaces, implemented differently (polymorphism). Inheritance, Polymorphism etc., Traditional testing Other unaltered methods within the subclass techniques can be adopted in Object Oriented may use the redefined method and need to environment by using the following techniques: be tested. Method testing Basis path, condition, data flow and loop Class testing tests can all apply to individual methods, Interaction testing but can’t test interactions between methods System testing 4.3 Integration Testing: Object Orientation does not Acceptance testing have a hierarchical control structure so conventional 4.1 Method Testing: Each individual method of the top-down and bottom up integration tests have little OO software has to be tested by the programmer. meaning. Integration testing can be applied in three This testing ensures Statement Coverage to ensure different incremental strategies: that all statements have been traversed atleast once, Thread-based testing, which integrates Decision Coverage to ensure all conditional classes required to respond to one input or executions and Path Coverage to ensure the execution event. the true and false part of the loop. Use-based testing, which integrates classes 4.2 Class Testing: Class testing is performed on the required by one use case. smallest testable unit in the encapsulated class. Each Cluster testing, which integrates classes operation as part of a class hierarchy has to be tested required to demonstrate one collaboration. because its class hierarchy defines its context of use. Integration testing is performed using the following New methods, inherited methods and redefined methods: methods within the class have to be tested. This For each client class, use the list of class testing is performed using the following approaches: methods to generate a series of random test Test each method (and constructor) within a sequences. Methods will send messages to class other server classes. 747 ISSN:2229-6093 Prashant ,Int.J.Computer Technology & Applications,Vol 3 (2), 746-749 For each message that is generated, careful attempt at "requirements elicitation". These determine the collaborating class and the scenarios will also tend to flush out interaction bugs. corresponding method in the server object. They are more complex and more realistic than fault For each method in the server object (that based tests often are. They tend to exercise multiple has been invoked by messages sent from the subsystems in a single test, exactly because that's client object), determine the messages that it what users do. The tests won't find everything, but transmits. they will at least cover the higher visibility For each of the messages, determine the next interaction bugs[4]. level of methods that are invoked and add 5.3 Surface Structure Testing: Object-oriented these into the test sequence. programming arguably encourages a different style of 4.4 System Testing: All rules and methods of interface. Rather than performing functions, users traditional systems testing are also applicable to may be given objects to fool around with in a direct object-oriented systems.