Interface TestingLifecycleHook
-
- All Implemented Interfaces:
public interface TestingLifecycleHookIf you need to hook into the testing lifecycle (e.g. you need to wait for any async operations to finish), provide your own custom implementation of this interface, then set it into testingLifecycleHook.
Since UI Unit Testing runs in the same JVM as the server and there is no browser, the boundaries between the client and the server become unclear. When looking into sources of any test method, it's really hard to tell where exactly the server request ends, and where another request starts.
You can establish an explicit client boundary in your test, by explicitly calling MockVaadin.clientRoundtrip. However, since that would be both laborous and error-prone, the default operation is that UI Unit Testing pretends as if there was a client-server roundtrip before every component lookup via the _get/_find/_expectNone/_expectOne call. Therefore, MockVaadin.clientRoundtrip is called from awaitBeforeLookup by default.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classTestingLifecycleHook.Companion
-
Method Summary
Modifier and Type Method Description UnitawaitBeforeLookup()Invoked before every component lookup. UnitawaitAfterLookup()Invoked after every component lookup. List<Component>getAllChildren(Component component)Provides all children of given component. -
-
Method Detail
-
awaitBeforeLookup
Unit awaitBeforeLookup()
Invoked before every component lookup. You can e.g. wait for any async operations to finish and for the server to settle down.
The default implementation calls the MockVaadin.clientRoundtrip method. When implementing this method, you should also call MockVaadin.clientRoundtrip (or simply call super).
-
awaitAfterLookup
Unit awaitAfterLookup()
Invoked after every component lookup. You can e.g. wait for any async operations to finish and for the server to settle down. Invoked even if the
_get()/_find()/_expectNone()function fails.
-
getAllChildren
List<Component> getAllChildren(Component component)
Provides all children of given component. Provides workarounds for certain components:
For Grid.Column the function will also return cell components nested in all headers and footers for that particular column.
For MenuItemBase the function returns all items of a sub-menu.
-
-
-
-