Skip to content

Latest commit

 

History

History
41 lines (31 loc) · 1.52 KB

README.md

File metadata and controls

41 lines (31 loc) · 1.52 KB

Hamcrest Extra Matchers

Build Status codecov Codacy Badge Apache License

Useful matchers which are not part of the official Hamcrest.

Usage

The HasPropertyPath matcher is an extension on the regular HasProperty matcher to test deeper nesting. This is for example useful to test Neo4j deserialization:

@Test
public void shouldLoadItemClientAndPetForPetNamedPete() {
    Item item = repository.loadItemClientAndPet(...);
    assertThat(item, hasPropertyPath("client.pet.name", is("Pete"));
}

In some cases, it is enough to know the path exists, no matter what value the property has:

@Test
public void shouldHavePathToPetName() {
    assertThat(item, hasPropertyPath("client.pet.name")); // is the same as
    assertThat(item, hasPropertyPath("client.pet.name", is(anything()));
}

Setup

Add to your project using Maven dependency:

<groupId>io.bitzl</groupId>
<artifactId>hamcrest-extras</artifactId>
<version>1.0.0-RELEASE</version>
<scope>test</scope>