Why Use Object-based Design in the Test Framework

20 March 2014

Object-based design helps not only to create simple-to-understand and easy-to-use hierarchical structure, but also assists in development of more flexible system. Object-based design typically helps to get higher level of abstraction that could increase understanding the difficulty and costs.

In addition to that it significantly decreases the time of test development and support. So, in some way this could work, but how to decrease both time and money? To explain this we should mention two approaches – behavior- or keyword-based.

Object-oriented design can be opposed to behavior–based (or keyword-based), though it wouldn`t be right. You can actually use object-based design along with almost any other design. With basic structure received from object-based design and simplicity of keyword-based test development you can benefit from both and get rid of negative effects.

Also object-based design based in some way on hierarchical patterns. Your test framework should use the class hierarchy to maximize the test coverage and to re-use tests or even test suites in subclasses. This approach is also the key to testing abstract classes. The hierarchical testing is based upon the “substitution principle” i.e. an instance of a subclass can be used anywhere as an instance of its super-class. This is generally considered to be one of the main rules of object-oriented programming, so using this in test framework can even encourage better object-oriented design.

When you shouldn’t apply object-based approach? If the tested system cannot be split apart into simple objects and is pure functional, consider another designs, they’ll go better.