Directory

karibu-testing-v23 - Vaadin Add-on Directory

Karibu Testing, support for browserless Vaadin testing in Kotlin karibu-testing-v23 - Vaadin Add-on Directory
The Unit Testing library for [Vaadin](https://vaadin.com/). When building apps with Vaadin Flow, your app manipulates Vaadin components server-side, while the browser is just a mere "reflection" of the server-side state (The "reflection" part - state transfer from server to client - is handled by Vaadin Flow). To test your app, you want your tests to focus on the server-side where your logic resides, while skipping the "unimportant" browser part "distraction". Karibu-Testing gives you the ability to call `UI.getCurrent()` straight from your JUnit test methods, and receive a meaningful result in the process. You can call `UI.navigate()` to navigate around in your app; you can instantiate your components and views directly from your JUnit test methods. In order to do so, Karibu-Testing mocks `CurrentRequest`, `VaadinSession` and others in your currently running JVM (in which your JUnit tests run). Karibu-Testing only runs in JVM and only tests server-side code. There is no browser running and no JavaScript code running, which means that there is no communication between the browser and the server, which means that you don't even need to run the servlet container. You simply create new instance of your Vaadin form, modify the field values directly, then simulate a click to the "Save" button and see the binder validations running. You can even call `UI.navigate()` to navigate to a view; the navigation is handled completely server-side and adds components to `UI.getCurrent()`. You then assert on the contents of `UI.getCurrent()` to verify that your code ran properly. In short, Karibu-Testing is here to perform: 1. *containerless testing*: You don't need to launch the servlet container. Karibu-Testing creates Vaadin Session, the UI and other necessary Vaadin classes straight in the JVM which runs your JUnit tests. 2. *browserless testing*: You look up components straight from `UI.getCurrent()`, bypassing browser and the JavaScript->Server bridge completely. You directly call methods on your server-side View classes and on the server-side Java Vaadin components. Check out a [30 second video of live coding with Karibu-Testing](https://www.youtube.com/watch?v=znVNEo9cj98) to get a taste on how simple this library is. The library supports Kotlin, Java and Groovy (Groovy support for Vaadin 14+ only).