Intent - Encapsulate a request as an object,
letting you parameterize clients with different requests,
queue or log requests, and support undoable operations.
Problem -
Actions need to be taken in a generic fashion, but
the requester of the action can't know (or need to know)
information about the request
Actions need to be run in sequence, or in different
ordering depending on who runs them, or why they are
being run.
Actions need to be re-run, or undone
Solution - Have all commands implement a generic
interface that allows the clients of the command to use
them in a generic manner. The clients of the command use
the simple interface instead of knowing all the details
about what the command does.
Participants and Collaborators
Command - (TestCase)
ConcreteCommand - (VectorTest)
Client - (TestRunner)
Invoker - (TestRunner)
Reciever - your code being tested
Consequences
Command decouples the object that invokes the
operation from the one that knows how to perform it.
Commands are first class objects, so they can be
extended and manipulated like any other object.
You can use the Composite pattern to assemble commands.
You can add new commands without changing existing classes.