![]() ![]() ![]() ![]() ![]() ![]() |
Scrunitizer uses some well known design pattern to achieve flexibility and
while still maintianing a clean architecure.
Composite![]() The Composite Pattern is used for organising all kind of test in tree like hierarchies, similar to files and directories. The abstract class Test is the basic Component for unit test hierarchies. Test Suites are the basic container object in Scruntizer, it could contain test cases and other test suites. So tests suite are composite objects. Test Cases are objects that directly perform some unit test functionality, so they are the Leafs in the test tree. Among being the grouping facility in Scrunitizer, The main benefit of using the Composite pattern in the test framework is that test cases and test suites could be treated the same in many places. Many interfaces like TestObserver, TestCiondcutor, TestSession and also TestSuite simply handle Test objects, regardless if the actual instance is a test case or a test suite. That makes handling of complex test trees as easy as dealing with only test cases alone.
Observer![]() Another pattern used extensively in Scrunitizer is the Observer pattern. Observers are used to monitor the ongoing test execution and to generate reports about the test outcome. Observers must implement the TestObserver interface. They observe basically two Subjects: Test sessions and tests. Whenever a session is started or comes to an end, observers are notified. The same with tests (test cases and test suites). Also test exceptions are handled by observers, but they are only products of the executions of a tests in a test session. AdapterThe Adapter pattern is used for different purposes in Scrunitizer.Function Adapter![]() If test cases are constructed from plain functions, it is required that the function to be used as test action (or for set-up and tear-down) has no parameters. This is necessary because a generic test class could not know what parameter value to use. But sometimes the function that should be used as test action has one or more parameters. That could even be quite useful to "parametrise" the test. In this situations, functions adapters are quite handy. The binder templates are Adapters that wrap a call statement around a function with parameters - the Adapatee - so that they are compatible with the signature of the Target, a functor. Functors are objects that support the function call operator, in this case the parameter-less function call.
Applicable Adapter![]() An applicable is an object that could be applied to other objects. In practice, Applicable is an interface template with an operation (apply) that takes an object pointer as input an executes an operation on that object. Typically this operation is a member function of the objects class. Now it becomes necessary to adapt arbitrary member functions to the Applicable interface. And like above, the Applicable interface supports only a parameter less apply function. So if member functions should be applied to objects, an adapter for applicables has to be used. Scrunitizer several Adapters template classes for member functions, the Adaptees, that wrap in the Target interface, Applicable. The reason why an template interface is used instead of offering templates that are directly integrated in test case adapter templates is twofold: First, this would lead to a huge number of templates for all combinations of member function and test case adapter templates, and second this would require also a lot of convenience template functions to easily select and instantiate the appropriate templates. Note that adapters are also used for other purposes in Scrunitizer:
by Bernd Linowski [Scrunitizer] [Overview] [Cookbook] [Download] [Index] [Linosphere] Page generated: 1 Nov 2000 (C) by Bernd Linowski scrunitizer@linosphere.de |