HamCrest is part of JUnit starting version 4.4.
It provides a library of matcher objects (also known as constraints or predicates) allowing ‘match’ rules to be defined declaratively, to be used in other frameworks. Typical scenarios include testing frameworks, mocking libraries and UI validation rules.
Using HamCrest, in JUnit you can now write assertions like the followings
It can also be used with mock objects frameworks by using adaptors to bridge from the mock objects framework’s concept of a matcher to a Hamcrest matcher.
Popularity: 1% [?]