SlideShare a Scribd company logo
Test-Driven 
Development with 
JavaFX
About us 
Sven Ruppert Hendrik Ebbers 
@hendrikEbbers 
www.guigarage.com 
@SvenRuppert 
www.rapidpm.org
Content 
• Testing 
• Testing 
• Testing 
Basics 
Frameworks 
CDI
Testing an application 
• unit tests 
how to test an UI component 
• integration tests 
• system tests 
how to test an UI workflow
manual testing 
• a tester tests the complete app 
• create a test plan 
• update the test plan for each 
release 
• test each release
CI / CD 
• update the test plan for each commit 
• test each commit 
we don’t want this
UI Test Tools & Libs
IDE based 
Tools like Selenium 
• QF-Test 
• commercial product 
• developer licence costs around 1995 € 
• no JUnit approach 
• CI integration 
• nearly the same as froglogic... 
Oct 2014
JemmyFX 
• is for JavaFX 2.2 
• last commit is over 2 years 
ago 
• looks like there is no 
development activity
Automaton 
• is for JavaFX2 
• is developed for Java7 (> u55), is 
running until Java8u11 
• written in Groovy 
• could test Swing and JavaFX 2 
• recommend TestFX for JavaFX 
see homepage
MarvinFX 
• https://github.com/guigarage/MarvinFX 
• Provides Supervisors for JavaFX Properties
MarvinFX 
define 
PropertySupervisor<String> textSupervisor = 
new PropertySupervisor<>(textfield.textProperty()); 
rules 
textPropertySupervisor.assertWillChange(); 
textPropertySupervisor.assertWillChangeByDefinedCount(3); 
textPropertySupervisor.assertWillChangeThisWay("A", "B", "C"); 
interaction 
//interact with UI by using TestFX 
check 
textPropertySupervisor.confirm();
TestFX
TestFX 
• active development 
• LTS branch for Java7 is 
available 
• active branch JavaFX8 only
TestFX 
• verifying the behavior of JavaFX 
applications 
• API for interacting with JavaFX applications. 
• fluent and clean API 
• Supports Hamcrest Matchers and Lambda 
expressions. 
• Screenshots of failed tests.
TestFX Deep Dive
Let’s start with a small app
Pseudo Code 
click(".text-field").type("steve"); 
click(".password-field").type("duke4ever"); 
click(".button:default"); 
assertNodeExists( ".dialog" );
step by step 
• Each test must extend the GuiTest class 
public class MyTest extends GuiTest { 
! 
@Test 
public void testLogin() { . . . } 
! 
}
step by step 
• Provide the root node in your GuiTest 
class 
public class MyTest extends GuiTest { 
! 
protected Parent getRootNode() { 
. . . 
} 
}
step by step 
• The GuiTest class provides a lot of 
functions that can be used to interact with 
JavaFX 
@Test 
public void testLogin() { 
click(„.text-field“); 
type("steve"); 
// . . . 
}
step by step 
• You can use the fluent API 
• You can use CSS selectors to find components 
@Test 
public void testLogin() { 
click(„#text-field“).type(„steve“); 
// . . . 
}
How to interact 
with a specific node?
Extended Node Search 
• TestFX provides additional search methods 
find(„#name-textfield“, find(„#edit-panel“)) 
find the textfield in the subpanel
Demo
View Objects Pattern
Any Idea what 
this test does? 
click("#user-field").type("steve"); 
click("#password-field").type("duke4ever"); 
click("#login-button"); 
click("#menu-button"); 
click("#action-35"); 
click("#tab-5"); 
click("#next"); 
click("#next"); 
click("#next"); 
click("#details"); 
assertNodeExists( "#user-picture" );
View Objects Pattern
View Objects Pattern 
• define a class / object for each view in 
your application 
SearchViewObject AlbumsViewObject 
TracksViewObject PlayViewObject
structure 
• Each user interaction is defined as a method 
• The class provides methods to check important 
states 
public class AlbumsViewObject { 
openAlbum(String name) {} 
checkAlbumCount(int count) {} 
assertContainsAlbum(String name) {} 
}
structure 
• Each method returns the view object for the page 
that is visible after the method has been executed 
• If the view won’t change by calling a method the 
method will return “this“ 
public TracksViewObject openAlbum(String name) { 
click((Text t) -> t.getText().contains(name)); 
return new TracksViewObject(getTestHandler()); 
} 
public AlbumsViewObject checkAlbumCount(int count) { 
assertEquals(count, getList().size()); 
return this; 
}
write readable tests 
@Test 
public void checkTrackCount() { 
new SearchView(this). 
search("Rise Against“). 
openAlbum("The Black Market“). 
checkTrackCountOfSelectedAlbum(12); 
}
Demo
Testing DataFX Flow 
public class Tests extends FlowTest { 
! 
protected Class<?> getFlowStartController() { 
return SearchController.class; 
} 
! 
@Test 
public void testSearch() { 
click(„#searchfield“) . . . 
} 
}
Injection
Problem 
@FlowScoped 
public class ITunesDataModel { 
! 
public void search(String artist) { 
//REST call 
} 
! 
}
extend the class 
@FlowScoped 
public class TestDataModel extends ITunesDataModel 
{ 
! 
public void search(String artist) { 
getAlbums().add(. . .); 
//Adding test data 
} 
! 
}
Solution for DataFX 
public class Tests extends FlowTest { 
! 
@Override 
protected void injectTestData(Injector injector) { 
injector.inject(new TestDataModel(), 
ITunesDataModel.class); 
} 
! 
}
Demo
Testing Afterburner.fx 
• apache licensed 
as lean as possible: 3 classes, no 
external dependencies 
• combines: FXML, Convention over 
Configuration and JSR-330 / @Inject 
• integrated with maven 3
Testing Afterburner.fx 
• under active development 
• injection over a few steps is working 
• postconstruct is working 
• using existing CDI Services with 
Annotations (Scopes and so on) is not 
working with afterburner 
• no mixed mode with CDI and afterburner.fx
Testing Afterburner.fx 
• TestFX is working fine with 
afterburner.fx 
• Definition of the tests are the 
same as without afterburner.fx
Demo Afterburner.fx
TestFX & CDI
Why CDI? 
• Because we want to use 
Mocks 
• Dynamic reconfiguration
Example 
Pa n e 
Controller 
Service
Example 
Pa n e 
Controller 
Service
Example 
Service myService = new Service(); 
@Inject Service myService;
Plain FX Demo
Example 
Pa n e 
Controller 
Mock 
Mock 
Mock 
Service
Example 
Pa n e 
Controller 
Mock 
Mock 
Service
Example 
Pa n e 
Controller 
Mock 
Service
CDI Basic Pattern 
• The production source must 
not contain test sources 
• Therefore we need to 
decouple test & production 
sources 
physically!
CDI Basic Pattern 
@Inject @MyQualifier 
ServiceInterface myService; 
creates 
@Producer @MyQualifier 
ServiceInterface createService(){. . .}
CDI Basic Pattern 
@Inject @MyQualifier 
ServiceInterface myService; 
@Producer @MyQualifier 
ServiceInterface createService(){. . .} 
Mock
CDI Basic Pattern 
if(„production“) { 
return service; 
} else { 
return mock; 
}
CDI Basic Pattern 
@Inject @MyQualifier 
ServiceInterface myService; 
@Producer @MyQualifier 
ServiceInterface createService(){. . .} 
Mock ?
CDI Basic Pattern 
@Inject @MyQualifier 
ServiceInterface myService; 
@Producer @MyQualifier 
ServiceInterface createService(){. . .} 
@Producer @Prod 
ServiceInterface create(){…} 
Mock 
@Producer @Mock 
ServiceInterface create(){…} 
src/main/java src/test/java
CDI Basic Pattern
CDI Basic Pattern
CDI Basic Pattern
CDI Demo
Where to start? 
• www.rapidpm.org 
• github.com/svenruppert/ 
javaone2014
QA

More Related Content

What's hot

The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
Andres Almiray
 
Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello World
Yakov Fain
 
JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)
Alexander Casall
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
Knoldus Inc.
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQuery
Knoldus Inc.
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0
Sumanth Chinthagunta
 
Java fx smart code econ
Java fx smart code econJava fx smart code econ
Java fx smart code econ
Tom Schindl
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web Application
Yakov Fain
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
Peter Drinnan
 
Desktop|Embedded Application API JSR
Desktop|Embedded Application API JSRDesktop|Embedded Application API JSR
Desktop|Embedded Application API JSR
Andres Almiray
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmine
Timothy Oxley
 
Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012
Hazem Saleh
 
The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
Andres Almiray
 
From Swing to JavaFX
From Swing to JavaFXFrom Swing to JavaFX
From Swing to JavaFX
Yuichi Sakuraba
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introduction
Nir Kaufman
 
Java and XPages
Java and XPagesJava and XPages
Java and XPages
Patrick Kwinten
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma intro
Maurice De Beijer [MVP]
 
Exploring Angular 2 - Episode 2
Exploring Angular 2 - Episode 2Exploring Angular 2 - Episode 2
Exploring Angular 2 - Episode 2
Ahmed Moawad
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
Michael Haberman
 

What's hot (19)

The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
 
Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello World
 
JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQuery
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0
 
Java fx smart code econ
Java fx smart code econJava fx smart code econ
Java fx smart code econ
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web Application
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
 
Desktop|Embedded Application API JSR
Desktop|Embedded Application API JSRDesktop|Embedded Application API JSR
Desktop|Embedded Application API JSR
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmine
 
Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012
 
The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
 
From Swing to JavaFX
From Swing to JavaFXFrom Swing to JavaFX
From Swing to JavaFX
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introduction
 
Java and XPages
Java and XPagesJava and XPages
Java and XPages
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma intro
 
Exploring Angular 2 - Episode 2
Exploring Angular 2 - Episode 2Exploring Angular 2 - Episode 2
Exploring Angular 2 - Episode 2
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
 

Similar to Test Driven Development with JavaFX

Qt test framework
Qt test frameworkQt test framework
Qt test framework
ICS
 
Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5
Jimmy Lu
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
Steven Smith
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
FalafelSoftware
 
Test driven development
Test driven developmentTest driven development
Test driven development
christoforosnalmpantis
 
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan KuštInfinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
Steven Smith
 
Unit tests and TDD
Unit tests and TDDUnit tests and TDD
Unit tests and TDD
Roman Okolovich
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
Gil Fink
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Ortus Solutions, Corp
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
 
3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API - 3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API -
Ortus Solutions, Corp
 
Automated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesAutomated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and Challenges
Tao Xie
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)
Rob Hale
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
Mats Bryntse
 
Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)
Joachim Baumann
 
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developers
Anton Udovychenko
 
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
Jen Wong
 
Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
nhm taveer hossain khan
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CI
wajrcs
 

Similar to Test Driven Development with JavaFX (20)

Qt test framework
Qt test frameworkQt test framework
Qt test framework
 
Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan KuštInfinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
 
Unit tests and TDD
Unit tests and TDDUnit tests and TDD
Unit tests and TDD
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
 
3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API - 3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API -
 
Automated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesAutomated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and Challenges
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
 
Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)
 
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developers
 
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
 
Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CI
 

More from Hendrik Ebbers

Java Desktop 2019
Java Desktop 2019Java Desktop 2019
Java Desktop 2019
Hendrik Ebbers
 
Java APIs- The missing manual (concurrency)
Java APIs- The missing manual (concurrency)Java APIs- The missing manual (concurrency)
Java APIs- The missing manual (concurrency)
Hendrik Ebbers
 
Beauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScriptBeauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScript
Hendrik Ebbers
 
Java 11 OMG
Java 11 OMGJava 11 OMG
Java 11 OMG
Hendrik Ebbers
 
Java APIs - the missing manual
Java APIs - the missing manualJava APIs - the missing manual
Java APIs - the missing manual
Hendrik Ebbers
 
Multidevice Controls: A Different Approach to UX
Multidevice Controls: A Different Approach to UXMultidevice Controls: A Different Approach to UX
Multidevice Controls: A Different Approach to UX
Hendrik Ebbers
 
Java WebStart Is Dead: What Should We Do Now?
Java WebStart Is Dead: What Should We Do Now?Java WebStart Is Dead: What Should We Do Now?
Java WebStart Is Dead: What Should We Do Now?
Hendrik Ebbers
 
Java ap is you should know
Java ap is you should knowJava ap is you should know
Java ap is you should know
Hendrik Ebbers
 
BUILDING MODERN WEB UIS WITH WEB COMPONENTS @ Devoxx
BUILDING MODERN WEB UIS WITH WEB COMPONENTS @ DevoxxBUILDING MODERN WEB UIS WITH WEB COMPONENTS @ Devoxx
BUILDING MODERN WEB UIS WITH WEB COMPONENTS @ Devoxx
Hendrik Ebbers
 
Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)
Hendrik Ebbers
 
webcomponents (Jfokus 2015)
webcomponents (Jfokus 2015)webcomponents (Jfokus 2015)
webcomponents (Jfokus 2015)
Hendrik Ebbers
 
JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)
Hendrik Ebbers
 
Feature driven development
Feature driven developmentFeature driven development
Feature driven development
Hendrik Ebbers
 
Extreme Gui Makeover
Extreme Gui MakeoverExtreme Gui Makeover
Extreme Gui Makeover
Hendrik Ebbers
 
JavaFX Enterprise
JavaFX EnterpriseJavaFX Enterprise
JavaFX Enterprise
Hendrik Ebbers
 
Bonjour for Java
Bonjour for JavaBonjour for Java
Bonjour for Java
Hendrik Ebbers
 
DataFX - JavaOne 2013
DataFX - JavaOne 2013DataFX - JavaOne 2013
DataFX - JavaOne 2013
Hendrik Ebbers
 
Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Hendrik Ebbers
 
Devoxx UK 2013: Sandboxing with the Vagrant-Binding API
Devoxx UK 2013: Sandboxing with the Vagrant-Binding APIDevoxx UK 2013: Sandboxing with the Vagrant-Binding API
Devoxx UK 2013: Sandboxing with the Vagrant-Binding API
Hendrik Ebbers
 
Vagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundVagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundHendrik Ebbers
 

More from Hendrik Ebbers (20)

Java Desktop 2019
Java Desktop 2019Java Desktop 2019
Java Desktop 2019
 
Java APIs- The missing manual (concurrency)
Java APIs- The missing manual (concurrency)Java APIs- The missing manual (concurrency)
Java APIs- The missing manual (concurrency)
 
Beauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScriptBeauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScript
 
Java 11 OMG
Java 11 OMGJava 11 OMG
Java 11 OMG
 
Java APIs - the missing manual
Java APIs - the missing manualJava APIs - the missing manual
Java APIs - the missing manual
 
Multidevice Controls: A Different Approach to UX
Multidevice Controls: A Different Approach to UXMultidevice Controls: A Different Approach to UX
Multidevice Controls: A Different Approach to UX
 
Java WebStart Is Dead: What Should We Do Now?
Java WebStart Is Dead: What Should We Do Now?Java WebStart Is Dead: What Should We Do Now?
Java WebStart Is Dead: What Should We Do Now?
 
Java ap is you should know
Java ap is you should knowJava ap is you should know
Java ap is you should know
 
BUILDING MODERN WEB UIS WITH WEB COMPONENTS @ Devoxx
BUILDING MODERN WEB UIS WITH WEB COMPONENTS @ DevoxxBUILDING MODERN WEB UIS WITH WEB COMPONENTS @ Devoxx
BUILDING MODERN WEB UIS WITH WEB COMPONENTS @ Devoxx
 
Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)
 
webcomponents (Jfokus 2015)
webcomponents (Jfokus 2015)webcomponents (Jfokus 2015)
webcomponents (Jfokus 2015)
 
JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)
 
Feature driven development
Feature driven developmentFeature driven development
Feature driven development
 
Extreme Gui Makeover
Extreme Gui MakeoverExtreme Gui Makeover
Extreme Gui Makeover
 
JavaFX Enterprise
JavaFX EnterpriseJavaFX Enterprise
JavaFX Enterprise
 
Bonjour for Java
Bonjour for JavaBonjour for Java
Bonjour for Java
 
DataFX - JavaOne 2013
DataFX - JavaOne 2013DataFX - JavaOne 2013
DataFX - JavaOne 2013
 
Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013
 
Devoxx UK 2013: Sandboxing with the Vagrant-Binding API
Devoxx UK 2013: Sandboxing with the Vagrant-Binding APIDevoxx UK 2013: Sandboxing with the Vagrant-Binding API
Devoxx UK 2013: Sandboxing with the Vagrant-Binding API
 
Vagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundVagrant-Binding JUG Dortmund
Vagrant-Binding JUG Dortmund
 

Recently uploaded

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 

Recently uploaded (20)

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 

Test Driven Development with JavaFX

  • 2. About us Sven Ruppert Hendrik Ebbers @hendrikEbbers www.guigarage.com @SvenRuppert www.rapidpm.org
  • 3. Content • Testing • Testing • Testing Basics Frameworks CDI
  • 4. Testing an application • unit tests how to test an UI component • integration tests • system tests how to test an UI workflow
  • 5. manual testing • a tester tests the complete app • create a test plan • update the test plan for each release • test each release
  • 6. CI / CD • update the test plan for each commit • test each commit we don’t want this
  • 7. UI Test Tools & Libs
  • 8. IDE based Tools like Selenium • QF-Test • commercial product • developer licence costs around 1995 € • no JUnit approach • CI integration • nearly the same as froglogic... Oct 2014
  • 9. JemmyFX • is for JavaFX 2.2 • last commit is over 2 years ago • looks like there is no development activity
  • 10. Automaton • is for JavaFX2 • is developed for Java7 (> u55), is running until Java8u11 • written in Groovy • could test Swing and JavaFX 2 • recommend TestFX for JavaFX see homepage
  • 11. MarvinFX • https://github.com/guigarage/MarvinFX • Provides Supervisors for JavaFX Properties
  • 12. MarvinFX define PropertySupervisor<String> textSupervisor = new PropertySupervisor<>(textfield.textProperty()); rules textPropertySupervisor.assertWillChange(); textPropertySupervisor.assertWillChangeByDefinedCount(3); textPropertySupervisor.assertWillChangeThisWay("A", "B", "C"); interaction //interact with UI by using TestFX check textPropertySupervisor.confirm();
  • 14. TestFX • active development • LTS branch for Java7 is available • active branch JavaFX8 only
  • 15. TestFX • verifying the behavior of JavaFX applications • API for interacting with JavaFX applications. • fluent and clean API • Supports Hamcrest Matchers and Lambda expressions. • Screenshots of failed tests.
  • 17. Let’s start with a small app
  • 18. Pseudo Code click(".text-field").type("steve"); click(".password-field").type("duke4ever"); click(".button:default"); assertNodeExists( ".dialog" );
  • 19. step by step • Each test must extend the GuiTest class public class MyTest extends GuiTest { ! @Test public void testLogin() { . . . } ! }
  • 20. step by step • Provide the root node in your GuiTest class public class MyTest extends GuiTest { ! protected Parent getRootNode() { . . . } }
  • 21. step by step • The GuiTest class provides a lot of functions that can be used to interact with JavaFX @Test public void testLogin() { click(„.text-field“); type("steve"); // . . . }
  • 22. step by step • You can use the fluent API • You can use CSS selectors to find components @Test public void testLogin() { click(„#text-field“).type(„steve“); // . . . }
  • 23. How to interact with a specific node?
  • 24. Extended Node Search • TestFX provides additional search methods find(„#name-textfield“, find(„#edit-panel“)) find the textfield in the subpanel
  • 25. Demo
  • 27. Any Idea what this test does? click("#user-field").type("steve"); click("#password-field").type("duke4ever"); click("#login-button"); click("#menu-button"); click("#action-35"); click("#tab-5"); click("#next"); click("#next"); click("#next"); click("#details"); assertNodeExists( "#user-picture" );
  • 29. View Objects Pattern • define a class / object for each view in your application SearchViewObject AlbumsViewObject TracksViewObject PlayViewObject
  • 30. structure • Each user interaction is defined as a method • The class provides methods to check important states public class AlbumsViewObject { openAlbum(String name) {} checkAlbumCount(int count) {} assertContainsAlbum(String name) {} }
  • 31. structure • Each method returns the view object for the page that is visible after the method has been executed • If the view won’t change by calling a method the method will return “this“ public TracksViewObject openAlbum(String name) { click((Text t) -> t.getText().contains(name)); return new TracksViewObject(getTestHandler()); } public AlbumsViewObject checkAlbumCount(int count) { assertEquals(count, getList().size()); return this; }
  • 32. write readable tests @Test public void checkTrackCount() { new SearchView(this). search("Rise Against“). openAlbum("The Black Market“). checkTrackCountOfSelectedAlbum(12); }
  • 33. Demo
  • 34. Testing DataFX Flow public class Tests extends FlowTest { ! protected Class<?> getFlowStartController() { return SearchController.class; } ! @Test public void testSearch() { click(„#searchfield“) . . . } }
  • 36. Problem @FlowScoped public class ITunesDataModel { ! public void search(String artist) { //REST call } ! }
  • 37. extend the class @FlowScoped public class TestDataModel extends ITunesDataModel { ! public void search(String artist) { getAlbums().add(. . .); //Adding test data } ! }
  • 38. Solution for DataFX public class Tests extends FlowTest { ! @Override protected void injectTestData(Injector injector) { injector.inject(new TestDataModel(), ITunesDataModel.class); } ! }
  • 39. Demo
  • 40. Testing Afterburner.fx • apache licensed as lean as possible: 3 classes, no external dependencies • combines: FXML, Convention over Configuration and JSR-330 / @Inject • integrated with maven 3
  • 41. Testing Afterburner.fx • under active development • injection over a few steps is working • postconstruct is working • using existing CDI Services with Annotations (Scopes and so on) is not working with afterburner • no mixed mode with CDI and afterburner.fx
  • 42. Testing Afterburner.fx • TestFX is working fine with afterburner.fx • Definition of the tests are the same as without afterburner.fx
  • 45. Why CDI? • Because we want to use Mocks • Dynamic reconfiguration
  • 46. Example Pa n e Controller Service
  • 47. Example Pa n e Controller Service
  • 48. Example Service myService = new Service(); @Inject Service myService;
  • 50. Example Pa n e Controller Mock Mock Mock Service
  • 51. Example Pa n e Controller Mock Mock Service
  • 52. Example Pa n e Controller Mock Service
  • 53. CDI Basic Pattern • The production source must not contain test sources • Therefore we need to decouple test & production sources physically!
  • 54. CDI Basic Pattern @Inject @MyQualifier ServiceInterface myService; creates @Producer @MyQualifier ServiceInterface createService(){. . .}
  • 55. CDI Basic Pattern @Inject @MyQualifier ServiceInterface myService; @Producer @MyQualifier ServiceInterface createService(){. . .} Mock
  • 56. CDI Basic Pattern if(„production“) { return service; } else { return mock; }
  • 57. CDI Basic Pattern @Inject @MyQualifier ServiceInterface myService; @Producer @MyQualifier ServiceInterface createService(){. . .} Mock ?
  • 58. CDI Basic Pattern @Inject @MyQualifier ServiceInterface myService; @Producer @MyQualifier ServiceInterface createService(){. . .} @Producer @Prod ServiceInterface create(){…} Mock @Producer @Mock ServiceInterface create(){…} src/main/java src/test/java
  • 63. Where to start? • www.rapidpm.org • github.com/svenruppert/ javaone2014
  • 64. QA