Interface TestContext
public interface TestContext
The test context is used for performing test assertions and manage the completion of the test. This context
is provided by vertx-unit as argument of the test case.
- Author:
- Julien Viet
-
Method Summary
Modifier and TypeMethodDescriptionassertEquals(Object expected, Object actual) Assert theexpectedargument is equals to theactualargument.assertEquals(Object expected, Object actual, String message) Assert theexpectedargument is equals to theactualargument.assertFalse(boolean condition) Assert the specifiedconditionisfalse.assertFalse(boolean condition, String message) Assert the specifiedconditionisfalse.assertInRange(double expected, double actual, double delta) Asserts that theexpecteddouble argument is equals to theactualdouble argument within a positive delta.assertInRange(double expected, double actual, double delta, String message) Asserts that theexpecteddouble argument is equals to theactualdouble argument within a positive delta.assertNotEquals(Object first, Object second) Assert thefirstargument is not equals to thesecondargument.assertNotEquals(Object first, Object second, String message) Assert thefirstargument is not equals to thesecondargument.assertNotNull(Object expected) Assert theexpectedargument is notnull.assertNotNull(Object expected, String message) Assert theexpectedargument is notnull.assertNull(Object expected) Assert theexpectedargument isnull.assertNull(Object expected, String message) Assert theexpectedargument isnull.assertTrue(boolean condition) Assert the specifiedconditionistrue.assertTrue(boolean condition, String message) Assert the specifiedconditionistrue.async()Create and returns a new async object, the returned async controls the completion of the test.async(int count) Create and returns a new async object, the returned async controls the completion of the test.<T> Handler<AsyncResult<T>> Creates and returns a new async handler, the returned handler controls the completion of 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.<T> Handler<AsyncResult<T>> Creates and returns a new async handler, the returned handler controls the completion of the test.<T> Handler<AsyncResult<T>> asyncAssertSuccess(Handler<T> resultHandler) Creates and returns a new async handler, the returned handler controls the completion of the test.voidfail()Throw a failure.voidThrow a failure with the specified failuremessage.voidThrow a failure with the specified failurecause.<T> TGet some data from the context.<T> TPut some data in the context.<T> TRemove some data from the context.strictAsync(int count) Create and returns a new async object, the returned async controls the completion of the test.Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework.
-
Method Details
-
get
Get some data from the context.- Type Parameters:
T- the type of the data- Parameters:
key- the key of the data- Returns:
- the data
-
put
-
remove
Remove some data from the context.- Parameters:
key- the key to remove- Returns:
- the removed object when it exists
-
assertNull
Assert theexpectedargument isnull. If the argument is not, an assertion error is thrown otherwise the execution continue.- Parameters:
expected- the argument being asserted to be null- Returns:
- a reference to this, so the API can be used fluently
-
assertNull
Assert theexpectedargument isnull. If the argument is not, an assertion error is thrown otherwise the execution continue.- Parameters:
expected- the argument being asserted to be nullmessage- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertNotNull
Assert theexpectedargument is notnull. If the argument isnull, an assertion error is thrown otherwise the execution continue.- Parameters:
expected- the argument being asserted to be not null- Returns:
- a reference to this, so the API can be used fluently
-
assertNotNull
Assert theexpectedargument is notnull. If the argument isnull, an assertion error is thrown otherwise the execution continue.- Parameters:
expected- the argument being asserted to be not nullmessage- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertTrue
Assert the specifiedconditionistrue. If the condition isfalse, an assertion error is thrown otherwise the execution continue.- Parameters:
condition- the condition to assert- Returns:
- a reference to this, so the API can be used fluently
-
assertTrue
Assert the specifiedconditionistrue. If the condition isfalse, an assertion error is thrown otherwise the execution continue.- Parameters:
condition- the condition to assertmessage- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertFalse
Assert the specifiedconditionisfalse. If the condition istrue, an assertion error is thrown otherwise the execution continue.- Parameters:
condition- the condition to assert- Returns:
- a reference to this, so the API can be used fluently
-
assertFalse
Assert the specifiedconditionisfalse. If the condition istrue, an assertion error is thrown otherwise the execution continue.- Parameters:
condition- the condition to assertmessage- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertEquals
Assert theexpectedargument is equals to theactualargument. If the arguments are not equals an assertion error is thrown otherwise the execution continue.- Parameters:
expected- the object the actual object is supposedly equals toactual- the actual object to test- Returns:
- a reference to this, so the API can be used fluently
-
assertEquals
Assert theexpectedargument is equals to theactualargument. If the arguments are not equals an assertion error is thrown otherwise the execution continue.- Parameters:
expected- the object the actual object is supposedly equals toactual- the actual object to testmessage- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertInRange
Asserts that theexpecteddouble argument is equals to theactualdouble argument within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise the execution continue.- Parameters:
expected- the object the actual object is supposedly equals toactual- the actual object to testdelta- the maximum delta- Returns:
- a reference to this, so the API can be used fluently
-
assertInRange
Asserts that theexpecteddouble argument is equals to theactualdouble argument within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise the execution continue.- Parameters:
expected- the object the actual object is supposedly equals toactual- the actual object to testdelta- the maximum deltamessage- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertNotEquals
Assert thefirstargument is not equals to thesecondargument. If the arguments are equals an assertion error is thrown otherwise the execution continue.- Parameters:
first- the first object to testsecond- the second object to test- Returns:
- a reference to this, so the API can be used fluently
-
assertNotEquals
Assert thefirstargument is not equals to thesecondargument. If the arguments are equals an assertion error is thrown otherwise the execution continue.- Parameters:
first- the first object to testsecond- the second object to testmessage- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
verify
Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework. AnyAssertionErrorthrown will be caught (and propagated) in order to fulfill potential expected async completeness.- Parameters:
block- block of code to be executed- Returns:
- a reference to this, so the API can be used fluently
-
fail
void fail()Throw a failure. -
fail
Throw a failure with the specified failuremessage.- Parameters:
message- the failure message
-
fail
Throw a failure with the specified failurecause.- Parameters:
cause- the failure cause
-
async
Async async()Create and returns a new async object, the returned async controls the completion of the test. Calling theAsync.complete()completes the async operation. The test case will complete when all the async objects have theirAsync.complete()method called at least once. This method shall be used for creating asynchronous exit points for the executed test.- Returns:
- the async instance
-
async
Create and returns a new async object, the returned async controls the completion of the test. This async operation completes when theAsync.countDown()is calledcounttimes. The test case will complete when all the async objects have theirAsync.complete()method called at least once. This method shall be used for creating asynchronous exit points for the executed test.- Returns:
- the async instance
-
strictAsync
Create and returns a new async object, the returned async controls the completion of the test. This async operation completes when theAsync.countDown()is calledcounttimes. IfAsync.countDown()is called more thancounttimes, anIllegalStateExceptionis thrown. The test case will complete when all the async objects have theirAsync.complete()method called at least once. This method shall be used for creating asynchronous exit points for the executed test.- Returns:
- the async instance
-
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.- Returns:
- the async result handler
-
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 invokes theresultHandlerargument 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.- Parameters:
resultHandler- the result handler- Returns:
- the async result handler
-
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.- Returns:
- the async result handler
-
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.- Parameters:
causeHandler- the cause handler- Returns:
- the async result handler
-
exceptionHandler
-