Nested class final
Marks a field that holds another class of tests, run as a group inside the outer class, with the same context and beans.
Use it to group tests that share a setup, such as "with one book in the basket": the nested class has its own BeforeEach methods, which run after the outer ones. Dart has no inner classes, so the group is a field whose value is an instance of a class declared in the same file. Disabled, Tag, TestOptions and DirtiesContext on the field (or on the nested class) apply to the whole group. TestBean fields are not allowed in the nested class: the context belongs to the outer one.
@SpringBootTest()
class BasketTest {
@Nested('with one book')
final withOneBook = WithOneBook();
}
class WithOneBook {
@Autowired()
late Basket basket; // the same bean as in the outer class
@BeforeEach()
void addBook() => basket.add('Dune', 10);
@Test()
void costsItsPrice() => expect(basket.total, 10);
}
Spring (Java): JUnit's @Nested on an inner class.
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited