Fork me on GitHub


What is Powerunit Extensions Matchers?

Powerunit Extensions Matchers is an extension to the Powerunit framework (not required), and provides support to generate Hamcrest Matchers for beans.


Why should I use Powerunit Extension Matchers?

Hamcrest is a very nice way to do assertion in unit test, but for complex beans, it may not be easy to test all fields by using getter.

By providing generation of hamcrest matchers, completion is available and null check is done on the bean itself.


How can I use Powerunit Extension Matchers?

Just add a dependency to ch.powerunit.extensions:powerunit-extensions-matchers and annotate a bean with @ProvideMatchers . Depending on the expectation, others configurations may be required to activate the annotation processor or change parameters.



How to generate matchers for a class ?

In short, just annotate the class with @ProvideMatchers .

Using this annotation indicates that a class, containing all generated matchers, must be generated. This class, by default, will have the same name and package that the annotated class, but with Matchers added to the end of the name.



What is the concept of extension in this framework ?

This framework, by itself, is able to generate various DSL for Pojo classes. In case some libraries are detected in the classpath, at compile time, specific DSL methods are added to use these library. This feature is available since version 0.1.0.