https://github.com/schwern/test-more/wiki/Subtest-Design
I've decided on a complete design for subtests and written it up, mostly to get it out of my head before I forget it. :-) Please let me know what you think. Here's a summary... In short, from a Test::Builder point of view, subtests do two things. 1. Set up a new test state isolated from the parent. 2. Communicate the result of the subtest back to the parent. Rather than have each EventHandler have a stack, each nested state has its own EventCoordinator (which contains all the EventHandlers). A stack of these coordinators are maintained by a TestState object (which doesn't exist yet) which delegates to the top of the stack. When a new test state is created, each EventHandler is asked to make a new handler for the subtest. Those are then attached to the new EventCoordinator. This isolates the subtest's state. Communication is accomplished by attaching the subtest's History object to a subtest_end event and passing this around to the parent's EventHandlers. They can do whatever they like with it and have as much information as the subtest did. This design tries to keep as much of the complexity of subtests away from the EventHandler and Formatter authors. Ideally an EventHandler does not need to be aware that it's nested while a Formatter just needs to know how deeply it's nested. -- emacs -- THAT'S NO EDITOR... IT'S AN OPERATING SYSTEM!