Fork me on GitHub

Frequently Asked Questions

General

  1. What is Powerunit Extensions Matchers?
  2. Why should I use Powerunit Extension Matchers?
  3. How can I use Powerunit Extension Matchers?

Usage

  1. How to generate matchers for a class ?

Extensions

  1. What is the concept of extension in this framework ?

Troubleshooting

  1. Why is the compilation failing because of missing annotation javax.annotation.Generated?
  2. Why is the compilation failing because of missing classes from org.hamcrest?
  3. The powerunit-extensions-matchers-providematchers and powerunit-extensions-matchers-factory artifacts are missing ?

General

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.

[top]


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.

[top]


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.

[top]

Usage

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.

[top]

Extensions

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.

[top]

Troubleshooting

Why is the compilation failing because of missing annotation javax.annotation.Generated?

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

[top]


Why is the compilation failing because of missing classes from org.hamcrest?

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

[top]


The powerunit-extensions-matchers-providematchers and powerunit-extensions-matchers-factory artifacts are missing ?

Since verson 0.2.0, these two artifacts are not generated anymore.

[top]