<dependency>
<groupId>org.linkki-framework</groupId>
<artifactId>linkki-vaadin-flow-test</artifactId>
</dependency>
Testing
Unit testing with Karibu-Testing
Karibu-Testing provides functionality to write browserless server-side JUnit Tests for Vaadin applications.
This allows calls such as UI.getCurrent() in a regular JUnit test by mocking VaadinSession, CurrentRequest and others.
linkki provides an extension of Karibu Testing.
Maven Dependency
Functionalities
linkki Karibu Extension provides following functionalities:
- KaribuUIExtension
-
The easiest 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 or instances in Vaadin UI tests, aKaribuUIExtensioncan be configured via the methodwithConfigurationand then added using@RegisterExtension. Additionally, a test usingKaribuUIExtensioncan be annotated with@WithLocaleto define the UI’s locale, defaulting to german.Example Usage@ExtendWith(KaribuUIExtension.class) class SimpleTestClassWithDefaultLocale { @Test void testLocale() { assertThat(UI.getCurrent()).isNotNull(); assertThat(UI.getCurrent().getLocale()).isEqualTo(Locale.GERMAN); } } @WithLocale("en") @ExtendWith(KaribuUIExtension.class) class SimpleTestClassWithLocaleEn { @Test void testLocale() { assertThat(UI.getCurrent()).isNotNull(); assertThat(UI.getCurrent().getLocale()).isEqualTo(Locale.ENGLISH); } } - KaribuUtils
-
The module also contains the utility class
KaribuUtilsthat makes it even easier to write Karibu tests, such as-
methods for handling
Notificationcomponents that are created withNotificationUtil -
methods for handling
OkCancelDialog -
support for push UI
-
methods for printing out the classnames of all components
-