vertx / io.vertx.ext.unit / TestSuite

# TestSuite

`interface TestSuite`

A named suite of test cases that are executed altogether. The suite suite is created with the `#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.

Author
Julien Viet

### Functions

after | `abstract fun after(callback: Handler<TestContext>): TestSuite` Set a callback executed after the tests.
afterEach | `abstract fun afterEach(callback: Handler<TestContext>): TestSuite` Set a callback executed after each test and before the suite `after` callback.
before | `abstract fun before(callback: Handler<TestContext>): TestSuite` Set a callback executed before the tests.
beforeEach | `abstract fun beforeEach(callback: Handler<TestContext>): TestSuite` Set a callback executed before each test and after the suite `before` callback.
create | `open static fun create(name: String): TestSuite` Create and return a new test suite. `open static fun create(testSuiteObject: Any): TestSuite` Create and return a new test suite configured after the `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` callback `after` : `#after` callback `beforeEach` : `#beforeEach` callback `afterEach` : `#afterEach` callback when the name starts with `test` :`#test` callback named after the method name
run | `abstract fun run(): TestCompletion` 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. Otherwise it is executed in the current thread. The returned Completion object can be used to get a completion callback. `abstract fun run(options: TestOptions): TestCompletion` 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 `io.vertx.ext.unit.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 `io.vertx.ext.unit.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. `abstract fun run(vertx: Vertx): TestCompletion` 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. The returned Completion object can be used to get a completion callback. `abstract fun run(vertx: Vertx, options: TestOptions): TestCompletion` 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 `io.vertx.ext.unit.TestOptions#setUseEventLoop(Boolean)` is not set to `false`. The returned Completion object can be used to get a completion callback.
test | `abstract fun test(name: String, testCase: Handler<TestContext>): TestSuite` `abstract fun test(name: String, repeat: Int, testCase: Handler<TestContext>): TestSuite` Add a new test case to the suite.