Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.junit.matchers
Class JUnitMatchers

    java.lang.Object
      org.junit.matchers.JUnitMatchers

    public class JUnitMatchers

extends java.lang.Object

Convenience import class: these are useful matchers for use with the assertThat method, but they are not currently included in the basic CoreMatchers class from hamcrest.

Constructor Summary
`JUnitMatchers()`

Method Summary
`static
`<T> org.junit.internal.matchers.CombinableMatcher<T>`
` | `both(org.hamcrest.Matcher<T> matcher)` This is useful for fluently combining matchers that must both pass.
`static org.hamcrest.Matcher<java.lang.String>` | `containsString(java.lang.String substring)`
`static
`<T> org.junit.internal.matchers.CombinableMatcher<T>`
` | `either(org.hamcrest.Matcher<T> matcher)` This is useful for fluently combining matchers where either may pass, for example:
`static
`<T> org.hamcrest.Matcher<java.lang.Iterable<T>>`
` | `everyItem(org.hamcrest.Matcher<T> elementMatcher)`
`static
`<T> org.hamcrest.Matcher<java.lang.Iterable<T>>`
` | `hasItem(org.hamcrest.Matcher<? extends T> elementMatcher)`
`static
`<T> org.hamcrest.Matcher<java.lang.Iterable<T>>`
` | `hasItem(T element)`
`static
`<T> org.hamcrest.Matcher<java.lang.Iterable<T>>`
` | `hasItems(org.hamcrest.Matcher<? extends T>... elementMatchers)`
`static
`<T> org.hamcrest.Matcher<java.lang.Iterable<T>>`
` | `hasItems(T... elements)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JUnitMatchers

    public JUnitMatchers()

Method Detail

### hasItem

    public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItem(T element)

  Parameters:
    `element` -
  Returns:
    A matcher matching any collection containing element

### hasItem

    public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItem(org.hamcrest.Matcher<? extends T> elementMatcher)

  Parameters:
    `elementMatcher` -
  Returns:
    A matcher matching any collection containing an element matching elementMatcher

### hasItems

    public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItems(T... elements)

  Parameters:
    `elements` -
  Returns:
    A matcher matching any collection containing every element in elements

### hasItems

    public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItems(org.hamcrest.Matcher<? extends T>... elementMatchers)

  Parameters:
    `elementMatchers` -
  Returns:
    A matcher matching any collection containing at least one element that matches each matcher in elementMatcher (this may be one element matching all matchers, or different elements matching each matcher)

### everyItem

    public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> everyItem(org.hamcrest.Matcher<T> elementMatcher)

  Parameters:
    `elementMatcher` -
  Returns:
    A matcher matching any collection in which every element matches elementMatcher

### containsString

    public static org.hamcrest.Matcher<java.lang.String> containsString(java.lang.String substring)

  Parameters:
    `substring` -
  Returns:
    a matcher matching any string that contains substring

### both

    public static <T> org.junit.internal.matchers.CombinableMatcher<T> both(org.hamcrest.Matcher<T> matcher)

  This is useful for fluently combining matchers that must both pass. For example:

         assertThat(string, both(containsString("a")).and(containsString("b")));

### either

    public static <T> org.junit.internal.matchers.CombinableMatcher<T> either(org.hamcrest.Matcher<T> matcher)

  This is useful for fluently combining matchers where either may pass, for example:

         assertThat(string, both(containsString("a")).and(containsString("b")));

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD