TestBench
Vaadin TestBench is a tool for creating and running browser based integration tests for your Vaadin application. TestBench simulates a user of your application, performs the tasks specified using Java code and verifies that the expected actions take place in the application.
TestBench can also visually inspect your application and detect unintentionally introduced changes, and verify that the application visually looks OK in all the browsers you are testing with. TestBench also includes special support for other Vaadin products, making testing easy and robust compared to generic web testing solutions.
Although not the main purpose of TestBench, you can also use TestBench to automate mundane tasks such as filling out forms.
A Typical Test
A typical test can look like:
-
Start a browser instance.
-
Chrome/Firefox/Safari/IE11/Edge are supported desktop browsers
-
iPhone/iPad/Android simulators are supported for mobile testing
-
-
Fill in the login form and log in to the application
-
Navigate to the order view
-
Fill in form fields to place an order
-
Verify that the order was placed
In Java code, this could be:
@Test
public void fillForm() {
setDriver(new ChromeDriver());
getDriver().get("http://localhost:8080");
LoginViewElement loginView = $(LoginViewElement.class).first();
MainViewElement mainView = loginView.login("admin@vaadin.com", "admin");
FormViewElement formView = mainView.navigateTo("form");
formView.clickNew();
formView.setName("John", "Doe");
formView.clickSave();
Assert.assertEquals("John Doe was added", formView.getMessage());
}
The code above uses the page object pattern to hide the implementation details of the view from the main test logic. For more information, see Creating Maintainable Test using Page Objects.
TestBench supports much more complex test cases, both regarding business logic (it’s Java, you can do whatever you want), and regarding running tests, e.g. executing on multiple browser instances in parallel, testing that an application works when multiple users interact simultaneously with the same view/data and comparing that the main view of the application still looks like the pregenerated reference screenshot.
Features
The main features of Vaadin TestBench are:
-
Control one or several browser instances from Java, both desktop and mobile browsers
-
A powerful and robust way to describe your tests so they do not break with application changes
-
A high level API for finding the component you want to interact with
-
Vaadin Component API for easy interaction with all Vaadin components and HTML elements
-
Automatic screen comparison highlighting differences
-
Assertion based UI state validation
-
Easily running tests in parallel
-
Test grid support for speeding up tests by running in parallel on multiple browsers on selected operating systems
-
Support for JUnit and other testing frameworks
-
All features available in Selenium
Commercial License
Vaadin TestBench is a commercial product and part of the Pro Subscription. You will be asked to validate your license or start a trial period when you start using the tool.