public class TestExpectations
extends java.lang.Object
Constructor and Description |
---|
TestExpectations() |
Modifier and Type | Method and Description |
---|---|
static <VALUE_TYPE> |
assertResponse(AssertionCall<VALUE_TYPE> assertion)
Alias for
assertValue(AssertionCall) . |
static <VALUE_TYPE> |
assertValue(AssertionCall<VALUE_TYPE> assertion)
Assert returned value with the given
AssertionCall |
static <T extends java.lang.Throwable> |
expectException(java.lang.Class<T> exception)
Expect that an exception of the given type should be thrown
|
static <T extends java.lang.Throwable> |
expectException(java.lang.Class<T> exception,
AssertionCall<T> assertion)
Expect that an exception of the given type should be thrown and be
asserted with the given
AssertionCall |
static <VALUE_TYPE,T extends java.lang.Throwable> |
expectExceptionInsteadOfValue(java.lang.Class<T> exception)
Exception is expected instead of call under test returning a value
|
static <VALUE_TYPE,T extends java.lang.Throwable> |
expectExceptionInsteadOfValue(java.lang.Class<T> exception,
AssertionCall<T> assertionCall)
Exception is expected instead of call under test returning a value and exception
is asserted with the given
AssertionCall |
static TestExpectation |
expectNotToFail()
Explicitly mark that a call shouldn't fail.
|
static <VALUE_TYPE> |
expectNotToFailIgnoringValue()
Return value variant of
expectNotToFail() |
static <VALUE_TYPE> |
expectValue(VALUE_TYPE value)
Shorthand method for asserting a single value.
|
public static <T extends java.lang.Throwable> TestExpectation expectException(java.lang.Class<T> exception)
T
- Type of exceptionexception
- Exception expectedpublic static <T extends java.lang.Throwable> TestExpectation expectException(java.lang.Class<T> exception, AssertionCall<T> assertion)
AssertionCall
T
- Type of the exceptionexception
- Exception expectedassertion
- Custom assertionpublic static TestExpectation expectNotToFail()
public static <VALUE_TYPE> TestValueExpectation<VALUE_TYPE> expectNotToFailIgnoringValue()
expectNotToFail()
VALUE_TYPE
- Type of the valuepublic static <VALUE_TYPE,T extends java.lang.Throwable> TestValueExpectation<VALUE_TYPE> expectExceptionInsteadOfValue(java.lang.Class<T> exception)
VALUE_TYPE
- Type of the return value of the call under testT
- Type of the exceptionexception
- Exception expectedpublic static <VALUE_TYPE,T extends java.lang.Throwable> TestValueExpectation<VALUE_TYPE> expectExceptionInsteadOfValue(java.lang.Class<T> exception, AssertionCall<T> assertionCall)
AssertionCall
VALUE_TYPE
- Type of the return value of the call under testT
- Type of the exceptionexception
- Exception expectedassertionCall
- Custom assertionpublic static <VALUE_TYPE> TestValueExpectation<VALUE_TYPE> assertValue(AssertionCall<VALUE_TYPE> assertion)
AssertionCall
VALUE_TYPE
- Type of the value to be assertedassertion
- Custom assertionpublic static <VALUE_TYPE> TestValueExpectation<VALUE_TYPE> assertResponse(AssertionCall<VALUE_TYPE> assertion)
assertValue(AssertionCall)
. Intended to be used
for example with RestAssured tests where the asserted value is an
HTTP response.VALUE_TYPE
- Type of the response to assertassertion
- Assertionpublic static <VALUE_TYPE> TestValueExpectation<VALUE_TYPE> expectValue(VALUE_TYPE value)
assertValue(value -> assertThat(value, is(1))
expectValue(1)
VALUE_TYPE
- Type of the valuevalue
- Value expected