public TestCaseExtension extends ProjectLevelExtension, SpecLevelExtension
Reusable extension that intercepts calls to a class TestCase.
These extensions can be registered project wide using
AbstractProjectConfig.extensions, or on a per-spec basis
by overriding extensions() in a interface Spec class, or finally
on individual tests themselves via class TestCaseConfig.
| Modifier and Type | Interface and Description |
|---|---|
static class |
TestCaseExtension.DefaultImpls
Reusable extension that intercepts calls to a
class TestCase. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
intercept(TestCase testCase,
kotlin.jvm.functions.Function3<? super io.kotlintest.TestCase,? super kotlin.jvm.functions.Function2<? super io.kotlintest.TestResult,? super kotlin.coroutines.experimental.Continuation<? super kotlin.Unit>,? extends java.lang.Object>,? super kotlin.coroutines.experimental.Continuation<? super kotlin.Unit>,? extends java.lang.Object> execute,
kotlin.jvm.functions.Function2<? super io.kotlintest.TestResult,? super kotlin.coroutines.experimental.Continuation<? super kotlin.Unit>,? extends java.lang.Object> complete,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> p)
Intercepts a
class TestCase. |
java.lang.Object intercept(TestCase testCase, kotlin.jvm.functions.Function3<? super io.kotlintest.TestCase,? super kotlin.jvm.functions.Function2<? super io.kotlintest.TestResult,? super kotlin.coroutines.experimental.Continuation<? super kotlin.Unit>,? extends java.lang.Object>,? super kotlin.coroutines.experimental.Continuation<? super kotlin.Unit>,? extends java.lang.Object> execute, kotlin.jvm.functions.Function2<? super io.kotlintest.TestResult,? super kotlin.coroutines.experimental.Continuation<? super kotlin.Unit>,? extends java.lang.Object> complete, kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> p)
Intercepts a class TestCase.
Allows implementations to add logic around a class TestCase as well as
control if (or when) the test is executed.
The supplied execute function should be invoked if implementations wish to
execute the test case.
This function requires the actual test case instance that will be executed, which is normally the same instance supplied, but can in fact be another. This allows you to change config for example:
execute(testCase.copy(config = ...))
The execute function additionally expects a callback function which will be invoked
with the class TestResult after the test has completed.
Implementations must invoke the complete function with a class TestResult
which is used to notify the underlying platform (eg, junit5)
as to the outcome of the test.
Typically the result recieved in the callback will be then used to invoke the complete function but this is not required. Implementations may wish to skip or abort the test case and invoke complete without ever running the test.
Or they may wish to run the test and then invoke complete with a different result to that received.
Note: !!Failure to invoke the complete function will result in the test runnner waiting indefinitely for the outcome of the test case!!
Note: A test cannot be skipped after it has been executed. Executing a test and then returning TestStatus.Ignored can result in errors on the JUnit platform.
testCase - the class TestCase under interception - contains the interface Spec
instance containing the class TestCase, the class TestCaseConfig to be passed to the test
and a class Description which contains the id and parent ids of the test case.execute - a function that is invoked to execute the test. Can be ignored if you
wish to return a class TestResult without executing the test itself.complete - a function that must be invoked with a class TestResult to
notify the test runner of the outcome of the test.class TestCase,
class TestCase,
class TestResult,
class TestResult