Testing with Karibu-Testing

linkki offers the option to write browserless server-side JUnit Tests using Karibu-Testing. Karibu allows for calling things like UI.getCurrent() in a regular JUnit test by mocking VaadinSession, CurrentRequest and others. To use this functionality simply include the Maven dependency for the module linkki-vaadin-flow-test like this:

<dependency>
    <groupId>org.linkki-framework</groupId>
    <artifactId>linkki-vaadin-flow-test</artifactId>
</dependency>

No other dependencies are required.

Using Karibu-Testing

The following classes are provided to use Karibu-Testing:

KaribuUIExtension

The simple way of using this module is by just annotating a test class with @ExtendWith(KaribuUIExtension.class). That will provide the basic Karibu funtionality. To register and use custom classes as routes in Vaadin UI tests, a KaribuUIExtension can be configured via the method withConfiguration and then added using @RegisterExtension. Additionally, a test using KaribuUIExtension can be annotated with @WithLocale to define the UI’s locale, defaulting to german.

KaribuUtils

The module also contains the utility class KaribuUtils to provides several useful utility methods. These include methods for handling Notification-components or for printing out the classnames of all Components.