Vaadin TestBench CSCI 3130 WINTER 2015
What’s TestBench A toolkit for testing user interfaces Based on Selenium Written in Java; interacts with HTML/CSS/JavaScript
Installing TestBench Already installed with Vaadin! Create a text file called “.vaadin.testbench.developer.license ” in your home directory Put the license key you are given into that file.
Installing TestBench Already installed with Vaadin! Create a text file called “.vaadin.testbench.developer.license ” in your home directory Put the license key you are given into that file.
Running JUnit Tests in Eclipse Just Right-Click the test file you want to run, then “Run As…” then “Unit Test”
Running JUnit Tests in Eclipse Just Right-Click the test file you want to run, then “Run As…” then “Unit Test”
Code Coverage A measure of how much of your code is run when you execute a test Eclipse can easily generate a report But you’ll want to run all your tests at once
Code Coverage A measure of how much of your code is run when you execute a test Eclipse can easily generate a report But you’ll want to run all your tests at once
Code Coverage A measure of how much of your code is run when you execute a test Eclipse can easily generate a report But you’ll want to run all your tests at once
Code Coverage A measure of how much of your code is run when you execute a test Eclipse can easily generate a report But you’ll want to run all your tests at once
Code Coverage A measure of how much of your code is run when you execute a test Eclipse can easily generate a report But you’ll want to run all your tests at once
Code Coverage A measure of how much of your code is run when you execute a test Eclipse can easily generate a report But you’ll want to run all your tests at once
Creating your first TestBench Test It’s already done! A test is generated when you make a new Vaadin Project
Creating your first TestBench Test It’s already done! A test is generated when you make a new Vaadin Project
How does testing work? 1. Creates a browser 2. Opens the application’s page 3. Looks for HTML elements 4. Makes sure the elements are right
Vaading Testing Architecture UI Display UI Control Business Logic ClientServer TestBench Standard JUnit
Components and Elements A widget by any other name… Components are what you use for laying out your UI (on the server) Each component has a corresponding element for testing (on the client)
Components and Elements
Element Selectors Let you find an element on a page Can be chained together Based on jQuery Start with $ Typically end with a first(), all() or get(index)
Element Selectors Let you find an element on a page Can be chained together Based on jQuery Start with $ Typically end with a first(), all() or get(index)
Using IDs and CSS classes Instead of relying on layout to find elements, give important elements an ID. Group important elements together with a CSS class.
Using IDs and CSS classes Instead of relying on layout to find elements, give important elements an ID. Group important elements together with a CSS class.
PageObject pattern Move all of the layout details to a separate class Test cases will call methods to retrieve certain elements
Sample Project Accessed at _trainer _trainer Running at rd_trainer rd_trainer