qa service

Testing Abstract Classes

Testing Abstract Classes
Defining The Goal of a Test Testing Abstract Classes

 

Usually, we expect that the root class of a derivation hierarchy (and, possibly, some of its direct descendants) is abstract. Now we will briefly discuss possible ways to test abstract classes like, say, MovableSprite and Sprite. Execution-based testing (inspection) of classes requires constructing instances of each class. Most object-oriented programming languages, including Java and C ++, support syntactic means for identifying abstract classes.

 

The formal semantics of programming languages ​​naturally prevents instances of abstract classes from being created. That poses a problem for testers, because one cannot create the required instances. There are several different approaches to testing abstract classes. Each of them has its strengths and weaknesses. We will  introduce these approaches in the context of testing the abstract Sprite class.

 

One of the approaches to testing abstract classes like Sprite is illustrated in Fig. below. In this approach, a specific subclass of Sprite is defined solely for testing purposes. In the picture, we assign the name ConcreteSprite to this class. The implementation of ConcreteSprite class defines a stub for each abstract operation in the Sprite class.

 

If one or more methods in Sprite class is a template method that uses one of abstract operations of Sprite class, then this abstract method must be provided with appropriate stubs

Screenshot_1

Figure. One approach to execution-based testing of an abstract class

 

such that it occurs to effectively satisfy the postconditions of the operation that is stubbed by it. In some instances, such a goal is achieved without much effort. For more complex operations, the writing of satisfactory stubs requires considerable effort. Once a particular class is implemented, the factory method called objectUnderTest () of the Tester class – for example, SpriteTester – creates an instance of the particular subclass.

 

Top 10 software testing companies have a worldwide mark with superior services therefore a number of their clients has reached its peak. However, these continue providing best qa and testing services, helping people manage their critical processes and activities to cut the costs of developing the highest quality systems.

 

One of the disadvantages of this approach is that the implementation of abstract methods cannot be simply extended to abstract subclasses without using the multiple inheritance relation. Consider, for example, what is needed to test the abstract class MovableSprite, which is a subclass of the abstract Sprite class.

 

Hire Testers in Ukraine

About the author

TestMatick

TestMatick is a leading provider of QA services.

Offering more than 20 types of QA services, we can cover absolutely every need in testing.

http://testmatick.com/

Add Comment

Click here to post a comment