jocarreira / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

Refinements #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This is a new concept in Hamcrest, orthogonal to Matchers.

A Refinement allows you to refine which part of the object is being tested.

e.g. 
assertThat(
  page, 
  inTable("sometable").cell("name", 0), // refinement 
  containsString("joe"));

This allows you to easiy navigate an object even if the methods aren't on
the object being tested (which is frequently the test).

LiFT does this well.

Original issue reported on code.google.com by joe.wal...@gmail.com on 14 Dec 2006 at 7:22

GoogleCodeExporter commented 8 years ago
Maybe Hamcrest needs a Function interface, like:

interface Function<FROM,TO> {
    public TO map(FROM value);
}

Original comment by nat.pr...@gmail.com on 1 Jun 2007 at 12:43

GoogleCodeExporter commented 8 years ago
There are already some refinements implemented as composite matchers.  E.g. the
hasProperty and hasToString matchers.  What's the difference between a proposed
refinement and a composite matcher? When matchers have rich diffing support I 
can't
see much advantage to adding a new concept.

Original comment by nat.pr...@gmail.com on 30 Jul 2007 at 1:34

GoogleCodeExporter commented 8 years ago
Rich diffing support is now implemented, so composite matchers do this.

Original comment by nat.pr...@gmail.com on 15 Oct 2008 at 9:08