public class Assertion extends Object
Modifier and Type | Field and Description |
---|---|
Assertion |
a |
Assertion |
all |
Assertion |
an |
Assertion |
and |
Assertion |
any |
Assertion |
at |
Assertion |
be |
Assertion |
been |
Assertion |
contain |
Assertion |
contains |
Assertion |
deep |
Assertion |
has |
Assertion |
have |
Assertion |
include |
Assertion |
includes |
Assertion |
is |
Assertion |
length |
Assertion |
not |
Assertion |
of |
Assertion |
same |
Assertion |
size |
Assertion |
that |
Assertion |
to |
Assertion |
which |
Assertion |
with |
Modifier and Type | Method and Description |
---|---|
Assertion |
a(Class<?> clazz)
An alias of
instanceOf(Class) |
Assertion |
a(Class<?> clazz,
String prefix)
An alias of
instanceOf(Class, String) |
void |
above(double n)
Same as
above(double, String) with no prefix set. |
void |
above(double n,
String prefix)
Asserts that the target is greater than `value`.
|
void |
above(long n)
Same as
above(long, String) with no prefix set. |
void |
above(long n,
String prefix)
Asserts that the target is greater than `value`.
|
Assertion |
an(Class<?> clazz)
An alias of
instanceOf(Class) |
Assertion |
an(Class<?> clazz,
String prefix)
An alias of
instanceOf(Class, String) |
void |
be(Object expected)
An alias of
equal(Object) |
void |
be(Object expected,
String prefix)
An alias of
equal(Object, String) |
void |
below(double n)
Same as
below(double, String) with no prefix set. |
void |
below(double n,
String prefix)
Asserts that the target is less than `value`.
|
void |
below(long n)
Same as
below(long, String) with no prefix set. |
void |
below(long n,
String prefix)
Asserts that the target is less than `value`.
|
Assertion |
cause() |
Assertion |
cause(Class<? extends Throwable> throwableClass) |
Assertion |
cause(Class<? extends Throwable> throwableClass,
Pattern errorPattern) |
Assertion |
cause(Class<? extends Throwable> throwableClass,
Pattern errorPattern,
String prefix) |
Assertion |
cause(Class<? extends Throwable> throwableClass,
String errorMessage) |
Assertion |
cause(Class<? extends Throwable> throwableClass,
String errorMessage,
String prefix) |
Assertion |
cause(Pattern errorPattern) |
Assertion |
cause(String errorMessage) |
Assertion |
cause(Throwable throwable) |
Assertion |
cause(Throwable throwable,
String prefix) |
Assertion |
causes() |
Assertion |
causes(Class<? extends Throwable> throwableClass) |
Assertion |
causes(Class<? extends Throwable> throwableClass,
Pattern errorMessage) |
Assertion |
causes(Class<? extends Throwable> throwableClass,
Pattern errorMessage,
String prefix) |
Assertion |
causes(Class<? extends Throwable> throwableClass,
String errorMessage) |
Assertion |
causes(Pattern errorMessage) |
Assertion |
causes(String errorMessage) |
Assertion |
causes(Throwable throwable) |
Assertion |
causes(Throwable throwable,
String prefix) |
Assertion |
change(Object bean,
String property) |
Assertion |
change(Object bean,
String property,
String prefix) |
Assertion |
changes(Object bean,
String property) |
Assertion |
changes(Object bean,
String property,
String prefix) |
void |
closeTo(double expected,
double delta) |
void |
closeTo(double expected,
double delta,
String prefix) |
void |
closeTo(long expected,
long delta) |
void |
closeTo(long expected,
long delta,
String prefix) |
Assertion |
contain(Object value)
Alias of
include(Object) |
Assertion |
contain(Object value,
String prefix)
Alias of
include(Object, String) |
Assertion |
contains(Object value)
Alias of
include(Object) |
Assertion |
contains(Object value,
String prefix)
Alias of
include(Object, String) |
Assertion |
decrease(Object bean,
String property) |
Assertion |
decrease(Object bean,
String property,
String prefix) |
Assertion |
decreases(Object bean,
String property) |
Assertion |
decreases(Object bean,
String property,
String prefix) |
void |
empty()
Same as
empty(String) with no prefix set. |
void |
empty(String prefix)
Asserts that the target's length is `0`.
|
void |
eq(Object expected)
An alias of
equal(Object) |
void |
eq(Object expected,
String prefix)
An alias of
equal(Object, String) |
void |
eql(Object expected) |
void |
eql(Object expected,
String prefix) |
void |
eqls(Object expected) |
void |
eqls(Object expected,
String prefix) |
void |
equal(Object expected)
Same as
equal(Object, String) with no prefix set. |
void |
equal(Object expected,
String prefix)
Asserts that the target is equal to the given value.
|
void |
greaterThan(double n)
Alias of
above(double) |
void |
greaterThan(double n,
String prefix)
Alias of
above(double, String) |
void |
greaterThan(long n)
Alias of
above(long) |
void |
greaterThan(long n,
String prefix)
Alias of
above(long, String) |
void |
gt(double n)
Alias of
above(double) |
void |
gt(double n,
String prefix)
Alias of
above(double, String) |
void |
gt(long n)
Alias of
above(long) |
void |
gt(long n,
String prefix)
Alias of
above(long, String) |
void |
gte(double n)
Alias of
least(double) |
void |
gte(double n,
String prefix)
Alias of
least(double, String) |
void |
gte(long n)
Alias of
least(long) |
void |
gte(long n,
String prefix)
Alias of
least(long, String) |
Assertion |
include(Object value)
Same as
include(Object, String) with no prefix set. |
Assertion |
include(Object value,
String prefix)
Asserts the inclusion of an object in an array/collection or a substring in a string.
|
Assertion |
includes(Object value)
Alias of
include(Object) |
Assertion |
includes(Object value,
String prefix)
Alias of
include(Object, String) |
Assertion |
increase(Object bean,
String property) |
Assertion |
increase(Object bean,
String property,
String prefix) |
Assertion |
increases(Object bean,
String property) |
Assertion |
increases(Object bean,
String property,
String prefix) |
Assertion |
instanceOf(Class<?> clazz)
Same as
instanceOf(Class, String) with no prefix set. |
Assertion |
instanceOf(Class<?> clazz,
String prefix)
The method
instanceOf asserts the class of a value. |
void |
keys(Collection<String> keys) |
void |
keys(Collection<String> keys,
String prefix) |
void |
keys(Map<String,?> keys) |
void |
keys(Map<String,?> keys,
String prefix) |
void |
keys(String... keys) |
void |
least(double n)
Same as
least(double, String) with no prefix set. |
void |
least(double n,
String prefix)
Asserts that the target is greater than or equal to `value`.
|
void |
least(long n)
Same as
least(long, String) with no prefix set. |
void |
least(long n,
String prefix)
Asserts that the target is greater than or equal to `value`.
|
Assertion |
length(int length)
Same as
length(int, String) with no prefix set. |
Assertion |
length(int length,
String prefix)
Asserts that the target's `length` has the expected value.
|
void |
lengthOf(int length)
Alias as
length(int) |
void |
lengthOf(int length,
String prefix)
Alias of
length(int, String) |
void |
lessThan(double n)
Alias of
below(double) |
void |
lessThan(double n,
String prefix)
Alias of
below(double, String) |
void |
lessThan(long n)
Alias of
below(long) |
void |
lessThan(long n,
String prefix)
Alias of
below(long, String) |
void |
lt(double n)
Alias of
below(double) |
void |
lt(double n,
String prefix)
Alias of
below(double, String) |
void |
lt(long n)
Alias of
below(long) |
void |
lt(long n,
String prefix)
Alias of
below(long, String) |
void |
lte(double n)
Alias of
most(double) |
void |
lte(double n,
String prefix)
Alias of
most(double, String) |
void |
lte(long n)
Alias of
most(long) |
void |
lte(long n,
String prefix)
Alias of
most(long, String) |
void |
match(Pattern pattern)
/**
Same as
match(Pattern, String) with no prefix set. |
void |
match(Pattern pattern,
String prefix)
Asserts that the target matches a regular expression.
|
void |
match(String regex)
/**
Same as
match(String, String) with no prefix set. |
void |
match(String regex,
String prefix)
Asserts that the target matches a regular expression.
|
void |
matches(Pattern regex)
Alias of
match(Pattern) |
void |
matches(Pattern pattern,
String prefix)
Alias of
match(Pattern, String) |
void |
matches(String regex)
Alias of
match(String) |
void |
matches(String regex,
String prefix)
Alias of
match(String, String) |
void |
members(Object... subset) |
void |
members(String prefix,
Object... subset) |
void |
most(double n)
Same as
most(double, String) with no prefix set. |
void |
most(double n,
String prefix)
Asserts that the target is less than or equal to `value`.
|
void |
most(long n)
Same as
most(long, String) with no prefix set. |
void |
most(long n,
String prefix)
Asserts that the target is less than or equal to `value`.
|
Assertion |
property(String path) |
Assertion |
property(String path,
Object expected) |
Assertion |
property(String path,
Object expected,
String prefix)
Asserts that the target has a property `name`, and that
the value of that property is equal to `value`.
|
Assertion |
size(int length)
Alias as
length(int) |
Assertion |
size(int length,
String prefix)
Alias of
length(int, String) |
void |
sizeOf(int length)
Alias as
length(int) |
void |
sizeOf(int length,
String prefix)
Alias of
length(int, String) |
void |
string(CharSequence expected) |
void |
string(CharSequence expected,
String prefix) |
void |
within(double start,
double finish)
Same as
within(double, double, String) with no prefix set. |
void |
within(double start,
double finish,
String prefix)
Asserts that the target is within a range.
|
void |
within(long start,
long finish)
Same as
within(long, long, String) with no prefix set. |
void |
within(long start,
long finish,
String prefix)
Asserts that the target is within a range.
|
public final Assertion to
public final Assertion be
public final Assertion been
public final Assertion is
public final Assertion and
public final Assertion has
public final Assertion have
public final Assertion with
public final Assertion that
public final Assertion which
public final Assertion at
public final Assertion of
public final Assertion same
public final Assertion a
public final Assertion an
public final Assertion all
public final Assertion not
public final Assertion deep
public final Assertion any
public final Assertion include
public final Assertion contain
public final Assertion includes
public final Assertion contains
public final Assertion length
public final Assertion size
public Assertion instanceOf(Class<?> clazz, String prefix)
instanceOf
asserts the class of a value.
expect(foo).to.be.an.instanceOf(Foo.class) expect("test").to.be.an.instanceOf(String.class)
clazz
- The class to check the value against.prefix
- A prefix that will be prepended to any error message generated by this assertion.public Assertion instanceOf(Class<?> clazz)
instanceOf(Class, String)
with no prefix set.clazz
- The class to check the value against.public Assertion a(Class<?> clazz)
instanceOf(Class)
public Assertion a(Class<?> clazz, String prefix)
instanceOf(Class, String)
public Assertion an(Class<?> clazz)
instanceOf(Class)
public Assertion an(Class<?> clazz, String prefix)
instanceOf(Class, String)
public void equal(Object expected, String prefix)
expect('hello').to.equal('hello'); expect(42).to.equal(42); expect(1).to.not.equal(true); expect({ foo: 'bar' }).to.not.equal({ foo: 'bar' }); expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' });
expected
- the expected value the target should be compared withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void equal(Object expected)
equal(Object, String)
with no prefix set.expected
- the expected value the target should be compared withpublic void eq(Object expected, String prefix)
equal(Object, String)
public void eq(Object expected)
equal(Object)
public void be(Object expected, String prefix)
equal(Object, String)
public void be(Object expected)
equal(Object)
public void eql(Object expected)
public void eqls(Object expected)
public void within(double start, double finish, String prefix)
expect(7).to.be.within(5, 10);Can also be used in conjunction with `length` to assert a length range. The benefit being a more informative error message than if the length was supplied directly.
expect("foo").to.have.length.within(2, 4); expect(new Integer[] { 1, 2, 3 }).to.have.length.within(2, 4);
start
- the lower bound (inclusive)finish
- the upper bound (inclusive)prefix
- A prefix that will be prepended to any error message generated by this assertion.public void within(double start, double finish)
within(double, double, String)
with no prefix set.start
- the lower bound (inclusive)finish
- the upper bound (inclusive)public void within(long start, long finish, String prefix)
expect(7L).to.be.within(5L, 10L);Can also be used in conjunction with `length` to assert a length range. The benefit being a more informative error message than if the length was supplied directly.
expect("foo").to.have.length.within(2L, 4L); expect(new Integer[] { 1, 2, 3 }).to.have.length.within(2L, 4L);
start
- the lower bound (inclusive)finish
- the upper bound (inclusive)prefix
- A prefix that will be prepended to any error message generated by this assertion.public void within(long start, long finish)
within(long, long, String)
with no prefix set.start
- the lower bound (inclusive)finish
- the upper bound (inclusive)public void above(double n, String prefix)
expect(10).to.be.above(5);Can also be used in conjunction with `length` to assert a minimum length. The benefit being a more informative error message than if the length was supplied directly.
expect("foo").to.have.length.above(2); expect(new Integer[] { 1, 2, 3 }).to.have.length.above(2);
n
- the value the target should be compared withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void greaterThan(double n, String prefix)
above(double, String)
public void gt(double n, String prefix)
above(double, String)
public void above(double n)
above(double, String)
with no prefix set.n
- the value the target should be compared withpublic void greaterThan(double n)
above(double)
public void gt(double n)
above(double)
public void above(long n, String prefix)
expect(10L).to.be.above(5L);Can also be used in conjunction with `length` to assert a minimum length. The benefit being a more informative error message than if the length was supplied directly.
expect("foo").to.have.length.above(2L); expect(new Integer[] { 1, 2, 3 }).to.have.length.above(2L);
n
- the value the target should be compared withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void greaterThan(long n, String prefix)
above(long, String)
public void gt(long n, String prefix)
above(long, String)
public void above(long n)
above(long, String)
with no prefix set.n
- the value the target should be compared withpublic void greaterThan(long n)
above(long)
public void gt(long n)
above(long)
public void least(double n, String prefix)
expect(10).to.be.at.least(10);Can also be used in conjunction with `length` to assert a minimum length. The benefit being a more informative error message than if the length was supplied directly.
expect("foo").to.have.length.of.at.least(2); expect(new Integer[] { 1, 2, 3 }).to.have.length.of.at.least(3);
n
- the value the target should be compared withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void gte(double n, String prefix)
least(double, String)
public void least(double n)
least(double, String)
with no prefix set.n
- the value the target should be compared withpublic void gte(double n)
least(double)
public void least(long n, String prefix)
expect(10L).to.be.at.least(10L);Can also be used in conjunction with `length` to assert a minimum length. The benefit being a more informative error message than if the length was supplied directly.
expect("foo").to.have.length.of.at.least(2L); expect(new Integer[] { 1, 2, 3 }).to.have.length.of.at.least(3L);
n
- the value the target should be compared withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void gte(long n, String prefix)
least(long, String)
public void least(long n)
least(long, String)
with no prefix set.n
- the value the target should be compared withpublic void gte(long n)
least(long)
public void below(double n, String prefix)
expect(5).to.be.below(10);Can also be used in conjunction with `length` to assert a maximum length. The benefit being a more informative error message than if the length was supplied directly.
expect("foo").to.have.length.below(4); expect(new Integer[] { 1, 2, 3 }).to.have.length.below(4);
n
- the value the target should be compared withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void lessThan(double n, String prefix)
below(double, String)
public void lt(double n, String prefix)
below(double, String)
public void below(double n)
below(double, String)
with no prefix set.n
- the value the target should be compared withpublic void lessThan(double n)
below(double)
public void lt(double n)
below(double)
public void below(long n, String prefix)
expect(5L).to.be.below(10L);Can also be used in conjunction with `length` to assert a maximum length. The benefit being a more informative error message than if the length was supplied directly.
expect("foo").to.have.length.below(4L); expect(new Integer[] { 1, 2, 3 }).to.have.length.below(4L);
n
- the value the target should be compared withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void lessThan(long n, String prefix)
below(long, String)
public void lt(long n, String prefix)
below(long, String)
public void below(long n)
below(long, String)
with no prefix set.n
- the value the target should be compared withpublic void lessThan(long n)
below(long)
public void lt(long n)
below(long)
public void most(double n, String prefix)
expect(5).to.be.at.most(5);Can also be used in conjunction with `length` to assert a maximum length. The benefit being a more informative error message than if the length was supplied directly.
expect("foo").to.have.length.of.at.most(4); expect(new Integer[] { 1, 2, 3 }).to.have.length.of.at.most(3);
n
- the value the target should be compared withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void lte(double n, String prefix)
most(double, String)
public void most(double n)
most(double, String)
with no prefix set.n
- the value the target should be compared withpublic void lte(double n)
most(double)
public void most(long n, String prefix)
expect(5L).to.be.at.most(5L);Can also be used in conjunction with `length` to assert a maximum length. The benefit being a more informative error message than if the length was supplied directly.
expect("foo").to.have.length.of.at.most(4L); expect(new Integer[] { 1, 2, 3 }).to.have.length.of.at.most(3L);
n
- the value the target should be compared withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void lte(long n, String prefix)
most(long, String)
public void most(long n)
most(long, String)
with no prefix set.n
- the value the target should be compared withpublic void lte(long n)
most(long)
public void match(Pattern pattern, String prefix)
expect("foobar").to.match(Pattern.compile("ˆfoo"));
pattern
- the Pattern
to match the target withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void matches(Pattern pattern, String prefix)
match(Pattern, String)
public void match(String regex, String prefix)
expect("foobar").to.match("ˆfoo");
regex
- the regular expression to match the target withprefix
- A prefix that will be prepended to any error message generated by this assertion.public void matches(String regex, String prefix)
match(String, String)
public void match(Pattern pattern)
match(Pattern, String)
with no prefix set.pattern
- the Pattern
to match the target withpublic void matches(Pattern regex)
match(Pattern)
public void match(String regex)
match(String, String)
with no prefix set.regex
- the regular expression to match the target withpublic void matches(String regex)
match(String)
public Assertion length(int length, String prefix)
expect(new Integer[] { 1, 2, 3 }).to.have.length(3); expect("foobar").to.have.length(6);
length
- the expected lengthprefix
- A prefix that will be prepended to any error message generated by this assertion.Assertion
on the lengthpublic Assertion size(int length, String prefix)
length(int, String)
public void lengthOf(int length, String prefix)
length(int, String)
public void sizeOf(int length, String prefix)
length(int, String)
public Assertion length(int length)
length(int, String)
with no prefix set.length
- the expected lengthAssertion
on the lengthpublic Assertion size(int length)
length(int)
public void lengthOf(int length)
length(int)
public void sizeOf(int length)
length(int)
public void empty(String prefix)
expect(new Object[]).to.be.empty; expect("").to.be.empty; expect(Collections.emptyList()).to.be.empty;
prefix
- A prefix that will be prepended to any error message generated by this assertion.public void empty()
empty(String)
with no prefix set.public Assertion include(Object value, String prefix)
expect(new Integer[] { 1, 2, 3 }).to.include(2); expect("foobar").to.contain("foo");
value
- the element/substring that is expected to be included in the targetprefix
- A prefix that will be prepended to any error message generated by this assertion.public Assertion includes(Object value, String prefix)
include(Object, String)
public Assertion contain(Object value, String prefix)
include(Object, String)
public Assertion contains(Object value, String prefix)
include(Object, String)
public Assertion include(Object value)
include(Object, String)
with no prefix set.value
- the element/substring that is expected to be included in the targetpublic Assertion includes(Object value)
include(Object)
public Assertion contain(Object value)
include(Object)
public Assertion contains(Object value)
include(Object)
public Assertion property(String path, Object expected, String prefix)
path
- path to the property that should be compared to the valueexpected
- the expected value of the propertyprefix
- A prefix that will be prepended to any error message generated by this assertion.public void string(CharSequence expected)
public void string(CharSequence expected, String prefix)
public void keys(Collection<String> keys)
public void keys(Collection<String> keys, String prefix)
public void keys(String... keys)
public Assertion cause(Class<? extends Throwable> throwableClass, String errorMessage, String prefix)
public Assertion cause(Class<? extends Throwable> throwableClass, Pattern errorPattern, String prefix)
public Assertion cause()
public Assertion causes(Class<? extends Throwable> throwableClass, Pattern errorMessage, String prefix)
public Assertion causes()
public void closeTo(double expected, double delta, String prefix)
public void closeTo(double expected, double delta)
public void closeTo(long expected, long delta, String prefix)
public void closeTo(long expected, long delta)
public void members(Object... subset)
Copyright © 2016. All rights reserved.