junit-team/junit — pull request #814 by bechte (2014-02-06 08:28:15+00:00)
Title: Description Builder for JUnit

Hi guys.

As of #198, I created a DescriptionBuilder that generates immutable Description classes.

In order to be backward compatible I extended the Description class with two new classes SuiteDescription & TestDescription that represent the two parts. In order to create a SuiteDescription you must now provide a list of children, whereas a TestDescription is generated without.

I didn't make use of the annotations, as it felt wrong and way to complicated to do so. With the builder pattern we can add individual attributes without blowing up the number of constructors. Moreover, clients may write their own builders and create subclasses of SuiteDescription or TestDescription for their own needs.

I think this is a solution that we can live with for a long time.

What I don't like is, that I needed to override the addChild() method to throw an Exception in order to make the subtypes immutable. Even though the addChild() method is marked deprecated and I added a warning JavaDoc for this, maybe there is a better way to solve this. Let me know if so.

I am looking forward to hearing your feedback.

All the best
bechte