Explain with example class testing.

Mumbai University > Information Technology > Sem 8 > Software Testing and Quality Assurance

Marks: 10 Marks

Difficulty : Medium

1 Answer

Object oriented software is based on concept of classes and objects. Therefore, smallest unit to be tested in a class.

There are some issues in class testing.

  1. A class can’t be tested directly first one need to create instances of class, as object then test it. Thus, abstract class cannot be tested, as its object can’t be created.

  2. The methods should be tested with reference to class or class hierarchy in the direction of complete testing of a class.

  3. Another important thing is inheritance is some classes have been derived from the bare class, them dependent class testing is not sufficient.

Feature based testing :

The features of class are categorized into six groups.

  • Create

  • Destroy

  • Moefiers

  • Predicates

  • Selectors

  • Iterators

State based testing :

  • State based testing is based on finite state customers that tests each feature with all its valid states.

  • State based testing tests interactions by monitoring effects that feature have on state of object.

  • The process of state based testing is:

    • Define the states.

    • Define the transistors between states.

    • Define test scenarios.

    • Define test values for each state.

Example for class testing: class to implement an integer stack class stack with following data item count, empty, full, pop max size.

So for testing this class following points must be considered.

  1. Item count cannot have negative.

  2. There is upper bound check on item count. I.e. item count ≤ max size.

  3. Empty stack i.e. item count = 0

  4. Full stack i.e. item count = max size.

Please log in to add an answer.