6.2. Recipes for defining new tests

The following recipes describe how to adapt the JUnit framework. This section presents the cookbook recipes for adapting the three main components of JUnit:

  • the definition of test cases

  • their combination into test suites

  • the adaptation of test reporting mechanisms.

Additionally, sample adaptations of JUnit demonstrate how to apply the cookbook recipes. The adaptations rely on test cases for a simple complex number class introduced in Example 6.4 and the UML-F diagram in Figure 6.7. It offers methods for accessing its attributes (the real and imaginary part of a complex number), as well as for adding and multiplying complex numbers.

Figure 6.7. The UML-F diagram of class ComplexNumber
Example 6.4. Java source ...

Get UML Profile for Framework Architectures, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.