Hamcrest connectors are divided into several modules. The "core" includes the most basic classes and abstract classes needed to build other helpers. org.hamcrest.CoreMatchers includes factory methods for these mappings only. Other matches are in the โlibraryโ module, grouped by the types of objects that they correspond to, and are optional. org.hamcrest.Matchers includes both sets of matches.
What should you use? I statically import all of the latter without a problem. It might take a little longer to compile, but this has never been a problem for me. I put this at the top of my unit tests in addition to importing JUnit:
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*;
This gives better readability in test methods.
David Harkness Jun 08 '12 at 20:45 2012-06-08 20:45
source share