Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bitzl/hamcrest-extra

Useful matchers which are not part of the official Hamcrest.
https://github.com/bitzl/hamcrest-extra

Last synced: 17 days ago
JSON representation

Useful matchers which are not part of the official Hamcrest.

Awesome Lists containing this project

README

        

# Hamcrest Extra Matchers
[![Build Status](https://travis-ci.org/bitzl/hamcrest-extra.svg?branch=master)](https://travis-ci.org/bitzl/hamcrest-extra)
[![codecov](https://codecov.io/gh/bitzl/hamcrest-extra/branch/master/graph/badge.svg)](https://codecov.io/gh/bitzl/hamcrest-extra)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/27f8c549f6424a7e88240b53907e4216)](https://www.codacy.com/app/marcus_2/hamcrest-extra?utm_source=github.com&utm_medium=referral&utm_content=bitzl/hamcrest-extra&utm_campaign=Badge_Grade)
[![Apache License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](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:

```java
@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:

```java
@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:

```xml
io.bitzl
hamcrest-extras
1.0.0-RELEASE
test
```