类 JUnitMatchers
- java.lang.Object
- org.junit.matchers.JUnitMatchers
public class JUnitMatchers extends 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.- 从以下版本开始:
- 4.4
构造器概要
构造器 构造器 说明 JUnitMatchers()
方法概要
所有方法 静态方法 具体方法 已过时的方法 修饰符和类型 方法 说明 static <T> CombinableMatcher.CombinableBothMatcher<T>
both(Matcher<? super T> matcher)
已过时。Please useCoreMatchers.both(Matcher)
instead.static Matcher<String>
containsString(String substring)
已过时。Please useCoreMatchers.containsString(String)
instead.static <T> CombinableMatcher.CombinableEitherMatcher<T>
either(Matcher<? super T> matcher)
已过时。Please useCoreMatchers.either(Matcher)
instead.static <T> Matcher<Iterable<T>>
everyItem(Matcher<T> elementMatcher)
已过时。Please useCoreMatchers.everyItem(Matcher)
instead.static <T> Matcher<Iterable<? super T>>
hasItem(Matcher<? super T> elementMatcher)
已过时。Please useCoreMatchers.hasItem(Matcher)
instead.static <T> Matcher<Iterable<? super T>>
hasItem(T element)
已过时。Please useCoreMatchers.hasItem(Object)
instead.static <T> Matcher<Iterable<T>>
hasItems(Matcher<? super T>... elementMatchers)
已过时。Please useCoreMatchers.hasItems(Matcher...)
instead.static <T> Matcher<Iterable<T>>
hasItems(T... elements)
已过时。Please useCoreMatchers.hasItems(Object...)
instead.static <T extends Exception>
Matcher<T>isException(Matcher<T> exceptionMatcher)
static <T extends Throwable>
Matcher<T>isThrowable(Matcher<T> throwableMatcher)
构造器详细资料
JUnitMatchers
public JUnitMatchers()
方法详细资料
hasItem
@Deprecated public static <T> Matcher<Iterable<? super T>> hasItem(T element)
已过时。Please useCoreMatchers.hasItem(Object)
instead.- 返回:
- A matcher matching any collection containing element
hasItem
@Deprecated public static <T> Matcher<Iterable<? super T>> hasItem(Matcher<? super T> elementMatcher)
已过时。Please useCoreMatchers.hasItem(Matcher)
instead.- 返回:
- A matcher matching any collection containing an element matching elementMatcher
hasItems
@Deprecated public static <T> Matcher<Iterable<T>> hasItems(T... elements)
已过时。Please useCoreMatchers.hasItems(Object...)
instead.- 返回:
- A matcher matching any collection containing every element in elements
hasItems
@Deprecated public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... elementMatchers)
已过时。Please useCoreMatchers.hasItems(Matcher...)
instead.- 返回:
- 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
@Deprecated public static <T> Matcher<Iterable<T>> everyItem(Matcher<T> elementMatcher)
已过时。Please useCoreMatchers.everyItem(Matcher)
instead.- 返回:
- A matcher matching any collection in which every element matches elementMatcher
containsString
@Deprecated public static Matcher<String> containsString(String substring)
已过时。Please useCoreMatchers.containsString(String)
instead.- 返回:
- a matcher matching any string that contains substring
both
@Deprecated public static <T> CombinableMatcher.CombinableBothMatcher<T> both(Matcher<? super T> matcher)
已过时。Please useCoreMatchers.both(Matcher)
instead.This is useful for fluently combining matchers that must both pass. For example:assertThat(string, both(containsString("a")).and(containsString("b")));
either
@Deprecated public static <T> CombinableMatcher.CombinableEitherMatcher<T> either(Matcher<? super T> matcher)
已过时。Please useCoreMatchers.either(Matcher)
instead.This is useful for fluently combining matchers where either may pass, for example:assertThat(string, either(containsString("a")).or(containsString("b")));
isThrowable
public static <T extends Throwable> Matcher<T> isThrowable(Matcher<T> throwableMatcher)
- 返回:
- A matcher that delegates to throwableMatcher and in addition appends the stacktrace of the actual Throwable in case of a mismatch.
isException
public static <T extends Exception> Matcher<T> isException(Matcher<T> exceptionMatcher)
- 返回:
- A matcher that delegates to exceptionMatcher and in addition appends the stacktrace of the actual Exception in case of a mismatch.