25
Vaadin TestBench CSCI 3130 WINTER 2015

Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench A toolkit for testing user interfaces Based on Selenium Written in Java; interacts with

Embed Size (px)

Citation preview

Page 1: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

Vaadin TestBenchCSCI 3130 WINTER 2015

Page 2: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

What’s TestBench

A toolkit for testing user interfaces

Based on SeleniumWritten in Java; interacts with

HTML/CSS/JavaScript

Page 3: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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.

Page 4: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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.

Page 5: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

Running JUnit Tests in Eclipse

Just Right-Click the test file you want to run, then “Run As…” then “Unit Test”

Page 6: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

Running JUnit Tests in Eclipse

Just Right-Click the test file you want to run, then “Run As…” then “Unit Test”

Page 7: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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

Page 8: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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

Page 9: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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

Page 10: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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

Page 11: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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

Page 12: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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

Page 13: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

Creating your first TestBench Test

It’s already done!A test is generated when you

make a new Vaadin Project

Page 14: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

Creating your first TestBench Test

It’s already done!A test is generated when you

make a new Vaadin Project

Page 15: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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

Page 16: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

Vaading Testing Architecture

UI Display

UI Control

Business Logic

Client Server

TestBench Standard JUnit

Page 17: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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)

Page 18: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

Components and Elements

Page 19: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

Element Selectors

Let you find an element on a page

Can be chained togetherBased on jQueryStart with $Typically end with a first(), all() or get(index)

Page 20: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

Element Selectors

Let you find an element on a page

Can be chained togetherBased on jQueryStart with $Typically end with a first(), all() or get(index)

Page 21: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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.

Page 22: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

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.

Page 23: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

PageObject pattern

Move all of the layout details to a separate class

Test cases will call methods to retrieve certain elements

Page 24: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with

Sample Project

Accessed at https://

github.com/dyule/card_trainerRunning at http://

mega.cs.dal.ca:8080/card_trainer

Page 25: Vaadin TestBench CSCI 3130 WINTER 2015. What’s TestBench  A toolkit for testing user interfaces  Based on Selenium  Written in Java; interacts with