CoreMatchers和Assert配合做junit
来源:互联网 发布:求50个的素数编程 编辑:程序博客网 时间:2024/06/06 06:43
CoreMatchers提供了很多匹配器,对于junit相对单薄的断言功能是很好的补充。
static <T> Matcher<T>
allOf(java.lang.Iterable<Matcher<? super T>> matchers)
Creates a matcher that matches if the examined object matches ALL of the specified matchers.
static <T> Matcher<T>
allOf(Matcher<? super T>... matchers)
Creates a matcher that matches if the examined object matches ALL of the specified matchers.
static <T> Matcher<T>
allOf(Matcher<? super T> first, Matcher<? super T> second)
Creates a matcher that matches if the examined object matches ALL of the specified matchers.
static <T> Matcher<T>
allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third)
Creates a matcher that matches if the examined object matches ALL of the specified matchers.
static <T> Matcher<T>
allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth)
Creates a matcher that matches if the examined object matches ALL of the specified matchers.
static <T> Matcher<T>
allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth)
Creates a matcher that matches if the examined object matches ALL of the specified matchers.
static <T> Matcher<T>
allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth, Matcher<? super T> sixth)
Creates a matcher that matches if the examined object matches ALL of the specified matchers.
static <T> Matcher<T>
any(java.lang.Class<T> type)
Creates a matcher that matches when the examined object is an instance of the specified
type
, as determined by calling the Class.isInstance(Object)
method on that type, passing the the examined object.static <T> AnyOf<T>
anyOf(java.lang.Iterable<Matcher<? super T>> matchers)
Creates a matcher that matches if the examined object matches ANY of the specified matchers.
static <T> AnyOf<T>
anyOf(Matcher<? super T>... matchers)
Creates a matcher that matches if the examined object matches ANY of the specified matchers.
static <T> AnyOf<T>
anyOf(Matcher<T> first, Matcher<? super T> second)
Creates a matcher that matches if the examined object matches ANY of the specified matchers.
static <T> AnyOf<T>
anyOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third)
Creates a matcher that matches if the examined object matches ANY of the specified matchers.
static <T> AnyOf<T>
anyOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth)
Creates a matcher that matches if the examined object matches ANY of the specified matchers.
static <T> AnyOf<T>
anyOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth)
Creates a matcher that matches if the examined object matches ANY of the specified matchers.
static <T> AnyOf<T>
anyOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth, Matcher<? super T> sixth)
Creates a matcher that matches if the examined object matches ANY of the specified matchers.
static Matcher<java.lang.Object>
anything()
Creates a matcher that always matches, regardless of the examined object.
static Matcher<java.lang.Object>
anything(java.lang.String description)
Creates a matcher that always matches, regardless of the examined object, but describes itself with the specified
String
.static <LHS> CombinableMatcher.CombinableBothMatcher<LHS>
both(Matcher<? super LHS> matcher)
Creates a matcher that matches when both of the specified matchers match the examined object.
static Matcher<java.lang.String>
containsString(java.lang.String substring)
Creates a matcher that matches if the examined
String
contains the specified String
anywhere.static <T> Matcher<T>
describedAs(java.lang.String description, Matcher<T> matcher, java.lang.Object... values)
Wraps an existing matcher, overriding its description with that specified.
static <LHS> CombinableMatcher.CombinableEitherMatcher<LHS>
either(Matcher<? super LHS> matcher)
Creates a matcher that matches when either of the specified matchers match the examined object.
static Matcher<java.lang.String>
endsWith(java.lang.String suffix)
Creates a matcher that matches if the examined
String
ends with the specified String
.static <T> Matcher<T>
equalTo(T operand)
Creates a matcher that matches when the examined object is logically equal to the specified
operand
, as determined by calling the Object.equals(java.lang.Object)
method on the examinedobject.static <U> Matcher<java.lang.Iterable<U>>
everyItem(Matcher<U> itemMatcher)
Creates a matcher for
Iterable
s that only matches when a single pass over the examined Iterable
yields items that are all matched by the specified itemMatcher
.static <T> Matcher<java.lang.Iterable<? super T>>
hasItem(Matcher<? super T> itemMatcher)
Creates a matcher for
Iterable
s that only matches when a single pass over the examined Iterable
yields at least one item that is matched by the specified itemMatcher
.static <T> Matcher<java.lang.Iterable<? super T>>
hasItem(T item)
Creates a matcher for
Iterable
s that only matches when a single pass over the examined Iterable
yields at least one item that is equal to the specified item
.static <T> Matcher<java.lang.Iterable<T>>
hasItems(Matcher<? super T>... itemMatchers)
Creates a matcher for
Iterable
s that matches when consecutive passes over the examined Iterable
yield at least one item that is matched by the corresponding matcher from the specifieditemMatchers
.static <T> Matcher<java.lang.Iterable<T>>
hasItems(T... items)
Creates a matcher for
Iterable
s that matches when consecutive passes over the examined Iterable
yield at least one item that is equal to the corresponding item from the specified items
.static <T> Matcher<T>
instanceOf(java.lang.Class<?> type)
Creates a matcher that matches when the examined object is an instance of the specified
type
, as determined by calling the Class.isInstance(Object)
method on that type, passing the the examined object.static <T> Matcher<T>
is(java.lang.Class<T> type)
已过时。
use isA(Class type) instead.
static <T> Matcher<T>
is(Matcher<T> matcher)
Decorates another Matcher, retaining its behaviour, but allowing tests to be slightly more expressive.
static <T> Matcher<T>
is(T value)
A shortcut to the frequently used
is(equalTo(x))
.static <T> Matcher<T>
isA(java.lang.Class<T> type)
A shortcut to the frequently used
is(instanceOf(SomeClass.class))
.static <T> Matcher<T>
not(Matcher<T> matcher)
Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match.
static <T> Matcher<T>
not(T value)
A shortcut to the frequently used
not(equalTo(x))
.static Matcher<java.lang.Object>
notNullValue()
A shortcut to the frequently used
not(nullValue())
.static <T> Matcher<T>
notNullValue(java.lang.Class<T> type)
A shortcut to the frequently used
not(nullValue(X.class)).
static Matcher<java.lang.Object>
nullValue()
Creates a matcher that matches if examined object is
null
.static <T> Matcher<T>
nullValue(java.lang.Class<T> type)
Creates a matcher that matches if examined object is
null
.static <T> Matcher<T>
sameInstance(T target)
Creates a matcher that matches only when the examined object is the same instance as the specified target object.
static Matcher<java.lang.String>
startsWith(java.lang.String prefix)
Creates a matcher that matches if the examined
String
starts with the specified String
.static <T> Matcher<T>
theInstance(T target)
Creates a matcher that matches only when the examined object is the same instance as the specified target object.
阅读全文
0 0
- CoreMatchers和Assert配合做junit
- Junit Assert
- Junit Assert
- junit.framework.Assert 与org.junit.Assert
- JUnit Assert方法总结
- JUnit Assert方法总结
- JUnit Assert方法总结
- JUnit Assertions vs assert
- JUnit Assert方法总结
- JUnit的assert方法
- junit 注解 及 Assert
- JUnit简介 and Assert
- JUnit Assert方法总结
- JUnit Assert方法总结
- JUnit Assert方法总结
- JUnit Assert方法总结
- JUnit之断言assert
- Junit中的Assert方法
- redis数据备份,迁移
- 第十一周——项目一—图及其存储结构(邻接矩阵、邻接表)算法库
- ios获取网络请求失败相关数据
- 【十八掌●武功篇】第八掌:HBase之基本操作Java API
- OpenCV移植到ARM(4)
- CoreMatchers和Assert配合做junit
- win10无法删除卷的解决办法
- Java中Long、String、Date 类型之间的转换
- 第十二周 【项目1
- Ubuntu 16.04安装Docker
- 字符串的操作函数
- Openstack(1)
- adb命令详解
- 分布式文件系统FastDFS设计原理