concept custom matcher in category java

appears as: custom matchers, custom matcher
JUnit in Action, Second Edition

This is an excerpt from Manning's book JUnit in Action, Second Edition.

Finally, Hamcrest is extremely extensible. It’s easy to write your own matchers that check a certain condition. The only thing you need to do is implement the Matcher interface and an appropriately named factory method. You can find more on how to write custom matchers in appendix D of this book, where we provide a complete overview of how to write your own matchers.

This appendix gives a brief introduction to how to extend the JUnit API with custom Runner objects. It also describes how to extend the Hamcrest API with custom matchers so that we eventually customize not only our runners but also our assert calls.

Figure B.2. Results from executing the tests, including the custom matcher