Class Overview
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.
Summary
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
Public Constructors
Public Methods
public
static
CombinableMatcher<T>
both
(Matcher<T> matcher)
This is useful for fluently combining matchers that must both pass. For example:
assertThat(string, both(containsString("a")).and(containsString("b")));
public
static
Matcher<String>
containsString
(String substring)
Returns
- a matcher matching any string that contains substring
public
static
CombinableMatcher<T>
either
(Matcher<T> matcher)
This is useful for fluently combining matchers where either may pass, for example:
assertThat(string, both(containsString("a")).and(containsString("b")));
public
static
Matcher<Iterable<T>>
everyItem
(Matcher<T> elementMatcher)
Returns
- A matcher matching any collection in which every element matches elementMatcher
public
static
Matcher<Iterable<T>>
hasItem
(T element)
Returns
- A matcher matching any collection containing element
public
static
Matcher<Iterable<T>>
hasItem
(Matcher<? extends T> elementMatcher)
Returns
- A matcher matching any collection containing an element matching elementMatcher
public
static
Matcher<Iterable<T>>
hasItems
(T... elements)
Returns
- A matcher matching any collection containing every element in elements
public
static
Matcher<Iterable<T>>
hasItems
(Matcher...<? extends T> 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)