Interface TestingLifecycleHook

  • All Implemented Interfaces:

    
    public interface TestingLifecycleHook
    
                        

    If 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.

    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Unit awaitBeforeLookup() Invoked before every component lookup.
      Unit awaitAfterLookup() Invoked after every component lookup.
      List<Component> getAllChildren(Component component) Provides all children of given component.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • 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.