On fx jsj unit - an idea to test javascript codes with junit and javafx
Upcoming SlideShare
Loading in...5

On fx jsj unit - an idea to test javascript codes with junit and javafx






Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

On fx jsj unit - an idea to test javascript codes with junit and javafx On fx jsj unit - an idea to test javascript codes with junit and javafx Presentation Transcript

  • On FxJsJUnitan idea to test JavaScript codes with JUnitand JavaFX
  • 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
  • Whats the Fx-Js-JUnit?● An library for testing JavaScript with Type safe assertion.● Applied JavaFXs WebEngine as a JavaScript Environment.● Based on these ideas and environment, we can test for JavaScript with JUnit, most popular testing framework.
  • Usage of Fx-Js-JUnit - the samplecode. - (1) Preparation for test.@ClassRulepublic static FxJsJUnit fxJsJUnit = FxJsJUnit.option(CoreExtension.class) .address("http://www.oracle.com") .identifiedBy(WebTest.class) .get();
  • Usage of Fx-Js-JUnit - the samplecode. - (2) getting IF for WebEngine.private JsJUnit jsJUnit;@Beforepublic void getTester() { jsJUnit = fxJsJUnit.getTester();}
  • Usage of Fx-Js-JUnit - the samplecode. - (3) calling JavaScript code.@Testpublic void testStringTest () { String result = jsJUnit.callAsString( "$(#input).text;" ); assertThat(result, is ("Input Here!"));}
  • Off course you can assert Plain OldJavaScript Object with POJO.@Testpublic 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));}
  • 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
  • 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 Im going to develop gradle- fxjsjunit-plugin and Jenkins-fsjsjunit-plugin.
  • 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 ■ (Im sorry this document is written in Japanese.)