2. Who writes this document?
● Name : mike_neck (Twitter @mike_neck)
● Jobs : No Jobs now!
○ If someone provide me a chance to have an
opportunity, I will try it! So ask me!
● Technologies :
○ Groovy
○ JavaScript
○ Java
○ Erlang
● Interested in : Concurrent Programings
3. What's the Fx-Js-JUnit?
● An library for testing JavaScript with Type
safe assertion.
● Applied JavaFX's WebEngine as a
JavaScript Environment.
● Based on these ideas and environment, we
can test for JavaScript with JUnit, most
popular testing framework.
4. Usage of Fx-Js-JUnit - the sample
code. - (1) Preparation for test.
@ClassRule
public static FxJsJUnit fxJsJUnit
= FxJsJUnit.option(CoreExtension.class)
.address("http://www.oracle.com")
.identifiedBy(WebTest.class)
.get();
5. Usage of Fx-Js-JUnit - the sample
code. - (2) getting IF for WebEngine.
private JsJUnit jsJUnit;
@Before
public void getTester() {
jsJUnit = fxJsJUnit.getTester();
}
6. Usage of Fx-Js-JUnit - the sample
code. - (3) calling JavaScript code.
@Test
public void testStringTest () {
String result = jsJUnit.callAsString(
"$('#input').text;"
);
assertThat(result, is ("Input Here!"));
}
7. Off course you can assert Plain Old
JavaScript Object with POJO.
@Test
public void personInitialization () {
Person person = new Person();
person.setName("mike");
person.setAge(35);
Person mike = jsJUnit.callAs(
"new Person('mike', 35)", Person.class);
assertThat(mike, is(person));
}
8. Architecture of Fx-Js-JUnit
4.call-function
Test
JavaFx
4.call-function
JsJUnit Test
5. call
WebEngine 4.call-function
Test
1.Launch 2.Prepare 3.execute
JUnit
9. TODOs and Problems/Difficulties
● Embbed Web Servers (Static Web Server)
/Servlet Containers (Tomcat / Jetty) /Java
EE Containers (Glassfish) to test total
Enterprise Application (TODO)
● Fx-Js-JUnit cannot be applied Concurrent
Test Execution. Because JavaFX cannot be
launched simultaneously and multiple times
without restart JVM(. It requires modification
of JUnit framework). (Problem/Difficulty)
○ to avoid this problem I'm going to develop gradle-
fxjsjunit-plugin and Jenkins-fsjsjunit-plugin.
10. Thank you for your attention.
Available resources ...
● GitHub
○ https://github.com/mike-neck/FxJsJUnit
● Another documents
○ http://www.slideshare.net/mikeneck/unit-testing-
java-script-with-javafx
■ (I'm sorry this document is written in Japanese.)