public final class TestBlock
extends java.lang.Object
A TestBlock
is usually created by calling
Cuppa.describe(String, TestBlockFunction)
or
Cuppa.when(String, TestBlockFunction)
but can be constructed using
TestBlockBuilder
.
TestBlock
s form a tree, which together contain all the tests defined in the program. There is always a
single root TestBlock
, which has the type TestBlockType.ROOT
.
For example, the following test code
describe("a", () -> { beforeEach("a-be1", () -> { }); it("a1"); describe("b", () -> { it("b1"); it("b3"); }); });
would result in a TestBlock tree of
root (TestBlock) | +-- a (TestBlock) | +-- a1 (Test) +-- a-be1 (Hook) +-- b (TestBlock) | +-- b1 (Test) +-- b2 (Test)
Modifier and Type | Field and Description |
---|---|
Behaviour |
behaviour
Controls how the test block and its descendants behave.
|
java.lang.String |
description
The description of the test block.
|
java.util.List<Hook> |
hooks
Hooks defined by the test block.
|
Options |
options
The set of options applied to the test block.
|
java.util.List<TestBlock> |
testBlocks
Nested test blocks.
|
java.lang.Class<?> |
testClass
The class that the test block was defined in.
|
java.util.List<Test> |
tests
Tests defined by the test block.
|
TestBlockType |
type
The type of the test block.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
java.util.List<Hook> |
hooksOfType(HookType type)
Get all the registered hooks of the given type, in the order they were defined.
|
TestBlockBuilder |
toBuilder()
Creates a
TestBlockBuilder and initialises it's properties to this TestBlock . |
java.lang.String |
toString() |
public final TestBlockType type
public final Behaviour behaviour
public final java.lang.Class<?> testClass
public final java.lang.String description
public final java.util.List<TestBlock> testBlocks
public final java.util.List<Hook> hooks
This list does not contain hooks from any of the nested blocks.
public final java.util.List<Test> tests
This list does not contain tests from any of the nested blocks.
public final Options options
public TestBlockBuilder toBuilder()
TestBlockBuilder
and initialises it's properties to this TestBlock
.TestBlockBuilder
.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object