public interface TestSuite
create(String)
and the returned suite contains initially no tests.
The suite can declare a callback before the suite with before(io.vertx.core.Handler)
or after
the suite with after(io.vertx.core.Handler)
.
The suite can declare a callback before each test with beforeEach(io.vertx.core.Handler)
or after
each test with afterEach(io.vertx.core.Handler)
.
Each test case of the suite is declared by calling the test(String, io.vertx.core.Handler)
method.Modifier and Type | Method and Description |
---|---|
TestSuite |
after(Handler<TestContext> callback)
Set a callback executed after the tests.
|
TestSuite |
afterEach(Handler<TestContext> callback)
Set a callback executed after each test and before the suite
after callback. |
TestSuite |
before(Handler<TestContext> callback)
Set a callback executed before the tests.
|
TestSuite |
beforeEach(Handler<TestContext> callback)
Set a callback executed before each test and after the suite
before callback. |
static TestSuite |
create(Object testSuiteObject)
Create and return a new test suite configured after the
testSuiteObject argument. |
static TestSuite |
create(String name)
Create and return a new test suite.
|
TestCompletion |
run()
Run the testsuite with the default options.
When the test suite is executed in a Vertx context (i.e `Vertx.currentContext()` returns a context) this
context's event loop is used for running the test suite.
|
TestCompletion |
run(TestOptions options)
Run the testsuite with the specified
options .
When the test suite is executed in a Vertx context (i.e `Vertx.currentContext()` returns a context) this
context's event loop is used for running the test suite unless the TestOptions.setUseEventLoop(Boolean)
is set to false . |
TestCompletion |
run(Vertx vertx)
Run the testsuite with the default options and the specified
vertx instance.
The test suite will be executed on the event loop provided by the vertx argument. |
TestCompletion |
run(Vertx vertx,
TestOptions options)
Run the testsuite with the specified
options and the specified vertx instance.
The test suite will be executed on the event loop provided by the vertx argument when
TestOptions.setUseEventLoop(Boolean) is not set to false . |
TestSuite |
test(String name,
Handler<TestContext> testCase)
Add a new test case to the suite.
|
TestSuite |
test(String name,
int repeat,
Handler<TestContext> testCase)
Add a new test case to the suite.
|
static TestSuite create(String name)
name
- the test suite namestatic TestSuite create(Object testSuiteObject)
testSuiteObject
argument.
The testSuiteObject
argument methods are inspected and the public, non static methods
with TestContext
parameter are retained and mapped to a Vertx Unit test suite
via the method name:
before
: before(io.vertx.core.Handler<io.vertx.ext.unit.TestContext>)
callbackafter
: after(io.vertx.core.Handler<io.vertx.ext.unit.TestContext>)
callbackbeforeEach
: beforeEach(io.vertx.core.Handler<io.vertx.ext.unit.TestContext>)
callbackafterEach
: afterEach(io.vertx.core.Handler<io.vertx.ext.unit.TestContext>)
callbacktest
:test(java.lang.String, io.vertx.core.Handler<io.vertx.ext.unit.TestContext>)
callback named after the method nametestSuiteObject
- the test suite objectTestSuite before(Handler<TestContext> callback)
callback
- the callbackTestSuite beforeEach(Handler<TestContext> callback)
before
callback.callback
- the callbackTestSuite after(Handler<TestContext> callback)
callback
- the callbackTestSuite afterEach(Handler<TestContext> callback)
after
callback.callback
- the callbackTestSuite test(String name, Handler<TestContext> testCase)
name
- the test case nametestCase
- the test caseTestSuite test(String name, int repeat, Handler<TestContext> testCase)
name
- the test case namerepeat
- the number of times the test should be repeatedtestCase
- the test caseTestCompletion run()
Completion
object can be used to get a completion callback.TestCompletion run(TestOptions options)
options
.
When the test suite is executed in a Vertx context (i.e `Vertx.currentContext()` returns a context) this
context's event loop is used for running the test suite unless the TestOptions.setUseEventLoop(Boolean)
is set to false
. In this case it is executed by the current thread.
Otherwise, the test suite will be executed in the current thread when TestOptions.setUseEventLoop(Boolean)
is
set to false
or null
. If the value is true
, this methods throws an IllegalStateException
.
The returned Completion
object can be used to get a completion callback.options
- the test optionsTestCompletion run(Vertx vertx)
vertx
instance.
The test suite will be executed on the event loop provided by the vertx
argument. The returned
Completion
object can be used to get a completion callback.vertx
- the vertx instanceTestCompletion run(Vertx vertx, TestOptions options)
options
and the specified vertx
instance.
The test suite will be executed on the event loop provided by the vertx
argument when
TestOptions.setUseEventLoop(Boolean)
is not set to false
. The returned
Completion
object can be used to get a completion callback.vertx
- the vertx instanceoptions
- the test optionsCopyright © 2022 Eclipse. All rights reserved.