Docs

Documentation versions (currently viewingVaadin 14)

You are viewing documentation for an older Vaadin version. View latest documentation

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 involve the following steps:

  1. Start a browser instance.

    • Chrome/Firefox/Safari/IE11/Edge are supported desktop browsers

    • iPhone/iPad/Android simulators are supported for mobile testing

  2. Fill in the login form and log in to the application

  3. Navigate to the order view

  4. Fill in form fields to place an order

  5. 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 Maintanable Test using Page Objects.

TestBench supports much more complex test cases, both in relation to the business logic and execution of tests. For example, you can execute tests on multiple browser instances in parallel. Doing so allows testing that the application works as expected when multiple users interact simultaneously with the same view or data.

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

938E9A1B-B017-451A-B3FD-67AE4A7495A5