public class TestContextImpl extends Object implements TestContext
| Constructor and Description |
|---|
TestContextImpl(Map<String,Object> attributes,
Handler<Throwable> unhandledFailureHandler) |
| Modifier and Type | Method and Description |
|---|---|
TestContext |
assertEquals(Object expected,
Object actual)
Assert the
expected argument is equals to the actual argument. |
TestContext |
assertEquals(Object expected,
Object actual,
String message)
Assert the
expected argument is equals to the actual argument. |
TestContext |
assertFalse(boolean condition)
Assert the specified
condition is false. |
TestContext |
assertFalse(boolean condition,
String message)
Assert the specified
condition is false. |
TestContext |
assertInRange(double expected,
double actual,
double delta)
Asserts that the
expected double argument is equals to the actual double argument
within a positive delta. |
TestContext |
assertInRange(double expected,
double actual,
double delta,
String message)
Asserts that the
expected double argument is equals to the actual double argument
within a positive delta. |
TestContext |
assertNotEquals(Object first,
Object second)
Assert the
first argument is not equals to the second argument. |
TestContext |
assertNotEquals(Object first,
Object second,
String message)
Assert the
first argument is not equals to the second argument. |
TestContext |
assertNotNull(Object expected)
Assert the
expected argument is not null. |
TestContext |
assertNotNull(Object expected,
String message)
Assert the
expected argument is not null. |
TestContext |
assertNull(Object expected)
Assert the
expected argument is null. |
TestContext |
assertNull(Object expected,
String message)
Assert the
expected argument is null. |
TestContext |
assertTrue(boolean condition)
Assert the specified
condition is true. |
TestContext |
assertTrue(boolean condition,
String message)
Assert the specified
condition is true. |
Async |
async()
Create and returns a new async object, the returned async controls the completion of the test.
|
Async |
async(int count)
Create and returns a new async object, the returned async controls the completion of the test.
|
<T> Handler<AsyncResult<T>> |
asyncAssertFailure()
Creates and returns a new async handler, the returned handler controls the completion of the test.
When the returned handler is called back with a failed result it completes the async operation.
When the returned handler is called back with a succeeded result it fails the test.
|
<T> Handler<AsyncResult<T>> |
asyncAssertFailure(Handler<Throwable> causeHandler)
Creates and returns a new async handler, the returned handler controls the completion of the test.
When the returned handler is called back with a failed result it completes the async operation.
When the returned handler is called back with a succeeded result it fails the test.
|
<T> Handler<AsyncResult<T>> |
asyncAssertSuccess()
Creates and returns a new async handler, the returned handler controls the completion of the test.
When the returned handler is called back with a succeeded result it completes the async operation.
When the returned handler is called back with a failed result it fails the test with the cause of the failure.
|
<T> Handler<AsyncResult<T>> |
asyncAssertSuccess(Handler<T> resultHandler)
Creates and returns a new async handler, the returned handler controls the completion of the test.
When the returned handler is called back with a succeeded result it invokes the
resultHandler argument
with the async result. |
Handler<Throwable> |
exceptionHandler() |
void |
fail()
Throw a failure.
|
void |
fail(String message)
Throw a failure with the specified failure
message. |
void |
fail(Throwable cause)
Throw a failure with the specified failure
cause. |
void |
failed(Throwable t) |
<T> T |
get(String key)
Get some data from the context.
|
<T> T |
put(String key,
Object value)
Put some data in the context.
|
<T> T |
remove(String key)
Remove some data from the context.
|
void |
run(Throwable failed,
long timeout,
Handler<TestContext> test,
Handler<Throwable> eh) |
Async |
strictAsync(int count)
Create and returns a new async object, the returned async controls the completion of the test.
|
TestContext |
verify(Handler<Void> block)
Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework.
|
public <T> T get(String key)
TestContextget in interface TestContextT - the type of the datakey - the key of the datapublic <T> T put(String key, Object value)
TestContextThis can be used to share data between different tests and before/after phases.
put in interface TestContextkey - the key of the datavalue - the datapublic <T> T remove(String key)
TestContextremove in interface TestContextkey - the key to removepublic void run(Throwable failed, long timeout, Handler<TestContext> test, Handler<Throwable> eh)
public void failed(Throwable t)
public Async async()
TestContextAsync.complete() completes the async operation.
The test case will complete when all the async objects have their Async.complete()
method called at least once.
This method shall be used for creating asynchronous exit points for the executed test.async in interface TestContextpublic Async async(int count)
TestContextAsync.countDown() is called count times.
The test case will complete when all the async objects have their Async.complete()
method called at least once.
This method shall be used for creating asynchronous exit points for the executed test.async in interface TestContextpublic Async strictAsync(int count)
TestContextAsync.countDown() is called count times.
If Async.countDown() is called more than count times, an IllegalStateException is thrown.
The test case will complete when all the async objects have their Async.complete()
method called at least once.
This method shall be used for creating asynchronous exit points for the executed test.strictAsync in interface TestContextpublic TestContext assertNull(Object expected)
TestContextexpected argument is null. If the argument is not, an assertion error is thrown
otherwise the execution continue.assertNull in interface TestContextexpected - the argument being asserted to be nullpublic TestContext assertNull(Object expected, String message)
TestContextexpected argument is null. If the argument is not, an assertion error is thrown
otherwise the execution continue.assertNull in interface TestContextexpected - the argument being asserted to be nullmessage - the failure messagepublic TestContext assertNotNull(Object expected)
TestContextexpected argument is not null. If the argument is null, an assertion error is thrown
otherwise the execution continue.assertNotNull in interface TestContextexpected - the argument being asserted to be not nullpublic TestContext assertNotNull(Object expected, String message)
TestContextexpected argument is not null. If the argument is null, an assertion error is thrown
otherwise the execution continue.assertNotNull in interface TestContextexpected - the argument being asserted to be not nullmessage - the failure messagepublic TestContext assertTrue(boolean condition, String message)
TestContextcondition is true. If the condition is false, an assertion error is thrown
otherwise the execution continue.assertTrue in interface TestContextcondition - the condition to assertmessage - the failure messagepublic TestContext assertTrue(boolean condition)
TestContextcondition is true. If the condition is false, an assertion error is thrown
otherwise the execution continue.assertTrue in interface TestContextcondition - the condition to assertpublic TestContext assertFalse(boolean condition)
TestContextcondition is false. If the condition is true, an assertion error is thrown
otherwise the execution continue.assertFalse in interface TestContextcondition - the condition to assertpublic TestContext assertFalse(boolean condition, String message)
TestContextcondition is false. If the condition is true, an assertion error is thrown
otherwise the execution continue.assertFalse in interface TestContextcondition - the condition to assertmessage - the failure messagepublic void fail()
TestContextfail in interface TestContextpublic void fail(String message)
TestContextmessage.fail in interface TestContextmessage - the failure messagepublic void fail(Throwable cause)
TestContextcause.fail in interface TestContextcause - the failure causepublic Handler<Throwable> exceptionHandler()
exceptionHandler in interface TestContextpublic TestContext assertEquals(Object expected, Object actual)
TestContextexpected argument is equals to the actual argument. If the arguments are not equals
an assertion error is thrown otherwise the execution continue.assertEquals in interface TestContextexpected - the object the actual object is supposedly equals toactual - the actual object to testpublic TestContext assertEquals(Object expected, Object actual, String message)
TestContextexpected argument is equals to the actual argument. If the arguments are not equals
an assertion error is thrown otherwise the execution continue.assertEquals in interface TestContextexpected - the object the actual object is supposedly equals toactual - the actual object to testmessage - the failure messagepublic TestContext assertInRange(double expected, double actual, double delta)
TestContextexpected double argument is equals to the actual double argument
within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise
the execution continue.assertInRange in interface TestContextexpected - the object the actual object is supposedly equals toactual - the actual object to testdelta - the maximum deltapublic TestContext assertInRange(double expected, double actual, double delta, String message)
TestContextexpected double argument is equals to the actual double argument
within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise
the execution continue.assertInRange in interface TestContextexpected - the object the actual object is supposedly equals toactual - the actual object to testdelta - the maximum deltamessage - the failure messagepublic TestContext assertNotEquals(Object first, Object second, String message)
TestContextfirst argument is not equals to the second argument. If the arguments are equals
an assertion error is thrown otherwise the execution continue.assertNotEquals in interface TestContextfirst - the first object to testsecond - the second object to testmessage - the failure messagepublic TestContext verify(Handler<Void> block)
TestContextAssertionError thrown will be caught (and propagated) in order to fulfill potential expected async
completeness.verify in interface TestContextblock - block of code to be executedpublic <T> Handler<AsyncResult<T>> asyncAssertSuccess()
TestContextasyncAssertSuccess in interface TestContextpublic <T> Handler<AsyncResult<T>> asyncAssertSuccess(Handler<T> resultHandler)
TestContextresultHandler argument
with the async result. The test completes after the result handler is invoked and does not fails.
When the returned handler is called back with a failed result it fails the test with the cause of the failure.
Note that the result handler can create other async objects during its invocation that would postpone
the completion of the test case until those objects are resolved.asyncAssertSuccess in interface TestContextresultHandler - the result handlerpublic <T> Handler<AsyncResult<T>> asyncAssertFailure()
TestContextasyncAssertFailure in interface TestContextpublic <T> Handler<AsyncResult<T>> asyncAssertFailure(Handler<Throwable> causeHandler)
TestContextasyncAssertFailure in interface TestContextcauseHandler - the cause handlerpublic TestContext assertNotEquals(Object first, Object second)
TestContextfirst argument is not equals to the second argument. If the arguments are equals
an assertion error is thrown otherwise the execution continue.assertNotEquals in interface TestContextfirst - the first object to testsecond - the second object to testCopyright © 2020. All rights reserved.