![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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/1.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/2.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/3.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/4.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/5.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/6.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/7.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/8.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/9.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/10.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/11.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/12.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/13.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/14.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/15.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/16.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/17.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/18.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/19.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/20.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/21.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/22.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/23.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/24.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062221/56649d755503460f94a56374/html5/thumbnails/25.jpg)