public Spec extends TestListener
A interface Spec is the top level component in KotlinTest.
It contains the root class TestCase instances which in turn
can contain nested class TestCase instances.
For example, the FunSpec allows us to create tests using the "test(name)" function, such as:
fun test("this is a test") { // test code here }
The spec ultimately forms a tree, with the spec's root container at the root, and nested containers forming branches and test cases as the leaves. The actual hierarchy will depend on the spec being used.
A interface Spec is also a interface TestListener to allow for
convenience overloads here if you just want to listen
in a single place.
| Modifier and Type | Interface and Description |
|---|---|
static class |
Spec.DefaultImpls
A
interface Spec is the top level component in KotlinTest. |
| Modifier and Type | Method and Description |
|---|---|
void |
closeResources() |
Description |
description() |
java.util.List<io.kotlintest.extensions.SpecLevelExtension> |
extensions()
Override this function to register extensions
which will be invoked during execution of this spec.
|
java.util.List<io.kotlintest.TestCase> |
focused()
Returns the focused tests for this Spec. Can be empty if no test is marked as focused.
|
boolean |
hasFocusedTest() |
boolean |
isInstancePerTest()
Deprecated.
|
IsolationMode |
isolationMode() |
java.util.List<io.kotlintest.extensions.TestListener> |
listeners()
Override this function to register instances of
interface TestListener which will be notified of events during
execution of this spec. |
java.util.Set<io.kotlintest.Tag> |
tags()
Any tags added here will be in applied to all
class TestCases defined
in this interface Spec in addition to any defined on the individual
tests themselves. |
TestCaseOrder |
testCaseOrder()
Sets the order of top level
class TestCases in this spec.
If this function returns a null value, then the value set in
the class AbstractProjectConfig will be used. |
java.util.List<io.kotlintest.TestCase> |
testCases()
These are the top level
class TestCase instances for this Spec. |
afterDiscovery, afterProject, afterSpec, afterSpec, afterSpecClass, afterSpecCompleted, afterTest, afterTest, beforeProject, beforeSpec, beforeSpec, beforeSpecClass, beforeSpecStarted, beforeTest, beforeTestboolean isInstancePerTest()
Returns true if this spec should use a new instance for each test case. This is the default behavior in jUnit.
If however you want a single instance to be shared for all tests in the same class, like ScalaTest, then this method should return false.
Note: Not all spec types support allowing one instance per test. This is due to implementation trickery required with nested closures and junit test discovery.
IsolationMode isolationMode()
java.util.List<io.kotlintest.extensions.SpecLevelExtension> extensions()
Override this function to register extensions which will be invoked during execution of this spec.
If you wish to register an extension across the project
then use AbstractProjectConfig.extensions.
AbstractProjectConfig.extensionsjava.util.List<io.kotlintest.extensions.TestListener> listeners()
Override this function to register instances of
interface TestListener which will be notified of events during
execution of this spec.
If you wish to register a listener that will be notified
for all specs, then use AbstractProjectConfig.listeners.
java.util.List<io.kotlintest.TestCase> testCases()
These are the top level class TestCase instances for this Spec.
class TestCasejava.util.List<io.kotlintest.TestCase> focused()
Returns the focused tests for this Spec. Can be empty if no test is marked as focused.
boolean hasFocusedTest()
void closeResources()
TestCaseOrder testCaseOrder()
Sets the order of top level class TestCases in this spec.
If this function returns a null value, then the value set in
the class AbstractProjectConfig will be used.
class TestCase,
class AbstractProjectConfigjava.util.Set<io.kotlintest.Tag> tags()
Any tags added here will be in applied to all class TestCases defined
in this interface Spec in addition to any defined on the individual
tests themselves.
class TestCase,
interface SpecDescription description()