Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing the Composite Pattern

Do you know well-tested and open source Composite examples in Smalltalk?

I would like to review example implementations of the Composite pattern in Smalltalk. Any dialect is fine, I am interested particularly in source code including unit test cases. This post describes what I am looking for, common testing snippets which can be re-used in my applications.

An well-designed implementation is useful too because I want to learn how composite tests are structured.

like image 335
user183928 Avatar asked Jan 30 '13 11:01

user183928


People also ask

What are test design patterns?

The Design patterns are defined as the best practices that a programmer must follow to amplify code reusability in a framework. The design pattern explains how to plan the test automation test ware to be useful and easy to maintain.

What is the composite pattern used for?

Composite pattern is used where we need to treat a group of objects in similar way as a single object. Composite pattern composes objects in term of a tree structure to represent part as well as whole hierarchy.

What type of pattern is composite pattern?

Composite pattern is a partitioning design pattern and describes a group of objects that is treated the same way as a single instance of the same type of object. The intent of a composite is to “compose” objects into tree structures to represent part-whole hierarchies.

Which best defines the use of the composite design pattern?

The Composite Design Pattern is meant to "compose objects into a tree structure to represent part-whole hierarchies. Composite Pattern lets clients treat individual objects and compositions of objects uniformly".


1 Answers

The composite pattern is extremely common in Smalltalk, I suspect almost any reasonably sized application has one or more uses of this design pattern. Some of the packages I know that contain a lot of tests include:

  • Refactoring engine: The refactoring engine contains dozens of composites, most prominent the model of the AST. It comes with a good collection of tests and is available in almost all Smalltalk dialects.

  • Seaside: This web application framework models request handlers, widgets, html tags, configurations, ... as composite objects. Again, it comes with a good collection of tests and is available on many Smalltalk platforms.

  • Pier: This content management system has various composites to model nested pages and their content. There are hundreds of tests that validate the construction, destruction and behaviour of these composite structures. The tests are structured across the hierarchy of the classes and many tests are reused on different kind of nodes.

like image 106
Lukas Renggli Avatar answered Oct 06 '22 21:10

Lukas Renggli