Modularization of the Fest Assertions library

The Fest Assertions library, a fluent Java API for writing assertions in your test or production code, is quite popular in my development team. Because of it's clean and fluent interface, it was no question to me when trying to use it in an Android project. But due to it's dependency on java.awt classes and due to Android's missing support for them, I currently cannot use it for writing tests in my Android codebase.

There might be several solutions to solve such an incompatibility, like adding classes providing missing packages in Android. Another solution is breaking the fest assertions library into several modules, so that one can use only Android compatible fest assertion modules. The library fest-assert is currently being refactored at GitHub, so nothing hinders us from forking and giving modularization a chance.

The whole approach is quite easy:

  • identify all awt dependent classes and corresponding resources in artifact A and move them to another artifact B.
  • for all commonly used classes between artifacts A and B, move them to a third artifact C, so that both A and B can be dependent on C.
  • in order to ease dependency management for users, create another artifact X, which itself depends on A and B.

Usually, most users should only depend on artifact X, which gives them most of the commonly used assertions. For special needs, you just drop your dependency on artifact X and replace it with one or more of the smaller modules. Using the example above, we have the following modules available:
A: fest-assert-core ( contains all core assertions, abstract base classes and the main API, but without dependencies on java.awt classes.
B: fest-assert-awt ( contains all awt assertions, which have simply been moved from the old core assertion library.
C: fest-test ( contains commonly used test classes. Some classes have been moved from the fest-assert-core artifact, to make them available for fest-assert-awt, too.
X: fest-assert ( A minimal artifact without Java classes, providing only dependencies on both fest-assert-core and fest-assert-awt. This artifact should be used in most cases, so that fest developers could continue modularization of fest-assert-core without breaking any client code. fest-assert should be used as facade to all commonly used assertion artifacts.

The only breaking change is a new factory class for the new awt specific artifact, in this case you would use "AwtAssertions" instead of "Assertions". You can find an example using both artifacts in on test class in the fest-examples repository (see the class MixedAssertionFactoriesTest). The whole modularized code can be found at the provided links, a discussion about this approach can be found at the fest easytesting developer group.

After discussion, I hope all changes find their way into the main repository at and further modularization will take place to make Fest Assertions compatible with GWT and other frameworks. In case you want to support or improve this approach, please provide feedback at the google group or at GitHub!