General
Usage
Extensions
Troubleshooting
Powerunit Extensions Matchers is an extension to the Powerunit framework (not required), and provides support to generate Hamcrest Matchers for beans.
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.
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.
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.
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.
Since version 9 of java, this annotation is not necessary available OOTB. You must add a dependency providing this annotation.
You may use this dependency javax.annotation:javax.annotation-api
Since version 0.2.0, the hamcrest dependency is not anymore included by this library. You must add this dependency yourself.
You may use one of these dependencies : org.hamcrest:hamcrest:2.2 ; org.hamcrest:hamcrest:2.1 ; org.hamcrest:hamcrest-all:1.3
Since verson 0.2.0, these two artifacts are not generated anymore.