Java (and original) version of Hamcrest

Clone this repo:
  1. 40465aa fixed arrayContaining(null, null). by sf105 · 10 years ago master
  2. 2a94ed2 Merge branch 'master' of by sf105 · 10 years ago
  3. bab1e3a in-line description strings from tests to remove unnecessary duplication. by scarytom · 10 years ago
  4. 89efa8c convert to JUnit 4 by scarytom · 10 years ago
  5. fcc7889 convert to JUnit4 and correct describeMismatch by scarytom · 10 years ago


Build Status

Java Hamcrest

Licensed under BSD License.

What is Hamcrest?

Hamcrest is a library of matchers, which can be combined in to create flexible expressions of intent in tests.


You can obtain Hamcrest binaries from maven central, or from google code downloads.


Depending on how you intend to use Hamcrest, you should use different Jars.

  • hamcrest-core.jar -- This is the core API to be used by third-party framework providers. This includes the a foundation set of matcher implementations for common operations. This API is stable and will rarely change. You will need this library as a minimum.
  • hamcrest-library.jar -- The ever-growing library of Matcher implementations. This will grow between releases.
  • hamcrest-generator.jar -- A tool to allow many Matcher implementations to be combined into a single class so users don't have to remember many classes/packages to import. Generates code.
  • hamcrest-integration.jar -- Provides integration between Hamcrest and other testing tools, including JUnit (3 and 4), TestNG, jMock and EasyMock.

Alternatively, if you don't care:

  • hamcrest-all.jar -- Includes all of the above.

Sources and JavaDoc jars are available for all of the above.


For Hamcrest extension projects see the hamcrest extensions page.


All libraries in the lib directory are used at build time, or are optional extras used for tighter integration with third party libraries.



Documentation can be found on the google code wiki.

Reporting Bugs/Issues

If you find an issue with Java Hamcrest, please report it via the GitHub issue tracker, after first checking that it hasn't been raised already. N.B. a few issues are still tracked using the old google code Issue tracker.


The complete source for Hamcrest is bundled. This includes:

  • Matcher core classes [src/core]
  • Matcher library [src/library]
  • Matcher integrations [src/integration]
  • Syntactic sugar generator [src/generator]
  • Unit tests [src/unit-test]
  • Ant build file [build.xml]
  • Dependencies [lib]

To build, please read BUILDING.txt



  • Joe Walnes
  • Nat Pryce
  • Steve Freeman


  • Robert Chatley
  • Tom White
  • Neil Dunn
  • Dan North
  • Magne Rasmussen
  • David Saff
  • Tom Denley

Also, thanks to everyone who has worked on DynaMock, nMock, jMock, EasyMock and MiniMock! These libraries inspired Hamcrest.