question archive Is unit testing possible or even desirable in all circumstances? Provide examples to justify your answer

Is unit testing possible or even desirable in all circumstances? Provide examples to justify your answer

Subject:Computer SciencePrice:2.89 Bought3

Is unit testing possible or even desirable in all circumstances? Provide examples to justify your answer.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Unit testing may not be possible in all situations and not desirable in all circumstances. The concept of unit testing changes when object oriented software is considered.

Encapsulation drives the definition of classes and objects. This means that each class and each instance of a class packages attributes and the operations that manipulate these data. An encapsulated class is usually the focus of unit testing. However, operations within the class are the smallest testable units. Because, a class can contain a number of different operations, and a particular operation may exist as a part of a number of different classes, the tactics applied to unit testing must change.

You can no longer test a single operation in isolation, but rather as part of a class. To illustrate, consider a class hierarchy in which an operation X is defined for the super class and is inherited by a number of subclasses. Each subclass uses operation X, but it is applied within the context of the private attributes and operations that have been defined for the subclass. Because the context in which operation X is used varies in subtle ways, it is necessary to test operation X in the context of each of the subclasses. This means that testing operation X in a stand-alone fashion is usually ineffective in the object-oriented context.

Related Questions