Link Search Menu Expand Document

JUnit: Hamcrest Matcher style

Hamcrest Matchers are an alternative to the ordinary style of writing asserts for JUnit testing.

Using Hamcrest with Maven


Using Hamcrest with Gradle

dependencies {
    // Unit testing dependencies
    testImplementation 'junit:junit:4.12'
    // Set this dependency if you want to use Hamcrest matching
    testImplementation 'org.hamcrest:hamcrest-library:1.3'

Additional Resources