Unit testing JavaScript with JUnit/JavaFX

  • Published on
    15-Jan-2015

  • View
    6.466

  • Download
    3

DESCRIPTION

Unit Testing Framework for JavaScript with Java

Transcript

  • 1. JUnitJavaScriptFx-Js-JUnit

2. JavaFX JavaScript 3. : @mike_neck : 181 : Groovy / JavaScript / Java mikemike 4. JavaJavaScript Fx-Js-JUnit 5. 6. JavaScript 7. QUnitjQueryPhantom.jsCUIJavaScript 8. SeleniumSeleniumWeb DriverUI 9. JavaJavaScript 10. Fx-Js-JUnit 11. Fx-Js-JUnit 12. Fx-Js-JUnit JavaFX2.0WebEngine JUnitJavaScript 13. JUnit 14. Web + DB #69JUnit 15. Server JavaFXJUnit Test 16. @ClassRule@ClassRuleprivate static UseFxJsJUnit fxJsJUnit =JavaFX UseFxJsJUnit.address(http://www.google.com) .identifiedBy(TestClass).get();private JsJUnit jsJUnit;@Before JavaScriptpublic void setUp () { jsJUnit = fxJsJUnit.getTester(); } 17. Long@Test public void longTest () {assertThat(jsJUnit.callLong(Integer.MAX_VALUE + " + 1"),is (Integer.MAX_VALUE + 1L));}@TestPersonpublic void personTest () {Person person = new Person();person.setName("mike");person.setAge(35);assertThat(jsJUnit.callAs("{name : mike, age : 35}",Person.class), is (person));} 18. Fx-Js-JUnitJavaScript 19. 20. Fx-Js-JUnit< > 21. The End 22. 23. 24. 25. 26. 27. JavaScript JavaFX JavaScriptJava 28. JavaFX-1 Application.launch(App.class); doSomething();Platform.exit(); 29. JavaFX-2 UIJavaFX WebEngine engine; engine.executeScript("1 + 1"); Platform.runLater({ engine.executeScript("1 + 1");} ); 30. JavaFX-3 UIJavaFXJavaFX Thread engine = new WebEngine(); WebEngineMain ThreadWebEngine engine; 31. JavaFX- JUnitWebView JUnitJavaFX JUnitJavaFX 32. java.util.concurrent.ExecutorService JavaFX java.util.concurrent.BlockingQueue JavaFX () javafx.application.Platform JavaFX 33. Java3,990JPYhttp://goo.gl/UUzc1 34. JSJavaWebEngineAPIhttp://docs.oracle.com/javafx/2/api/javafx/scene/web/WebEngine.html JavaScript values are represented using the obvious Java classes: null becomes Java null; a boolean becomes a java.lang.Boolean; and a string becomes a java.lang.String. A number can be java.lang.Double or a java.lang.Integer, depending...If the result is a JavaScript object, it is wrapped as an instance of the netscape. javascript.JSObject 35. JSJava JavaScript typeofJava Object Objectvaluenullobjectnull falseboolean java.lang.Boolean23numberjava.lang.Integer1.10numberjava.lang.Double"script"stringjava.lang.String 36. JSJavaWebEngineAPIhttp://docs.oracle.com/javafx/2/api/javafx/scene/web/WebEngine.html JavaScript values are represented using the obvious Java classes: null becomes Java null; a boolean becomes a java.lang.Boolean; and a string becomes a java.lang.String. A number can be java.lang.Double or a java.lang.Integer, depending...If the result is a JavaScript object, it is wrapped as an instance of the netscape. javascript.JSObject 37. JSJava JSObject... 38. JSJavaPlain Old JavaScript Object (POJSO)JSObject#getMember(){name : "cthuga", str : 80, con : 120, siz :140, pow : 42}JSObject cthuga = ...;assertThat((String)cthuga.getMember("name"),is ("cthuga") ); 39. JSJavaSAN 40. JSJavaDateJSObject date = ...;date.getMember("year");JSException 41. JSJavaJavaScriptDate Date POJSO 42. JSJavaJavaScriptvar Encapsulation = function() { var count = 0; this.addAndGet = function () { count ++; return count; }};var counter = new Encapsulation();return counter; 43. JSJava 44. JSJavaJSObjectPOJO 45. JSJava 46. JSJava 47. JSJava 48. JSJava 49. JSJava 50. JSJava 51. JSJavaPOJSO 52. JSJava 53. JSJavaPOJSO(int) jsObject.getMember("addAndGet"); 54. JSJavaDatePOJSO 55. JSJava 56. JSJavaassertion 57. JSJavaequals(java.lang.Object)hashCode() 58. JSJava assert POJSOgetMemberPOJOassert POJSOassert 59. Fx-Js-JUnitJavaScript 60. 61. Enjoy JavaScript! 62. 63. 64. 65. 66. SANdef service = Executors.newThreadPool(2)service.execute {Application.launch(App) }service.execute {Application.launch(App) } 67. 68. 69. + JavaFX 70. 71. JavaFX 72. WebEngine WebEngine 73. TODOs ServletJavaEE GitHub Maven/Ivy @mike_neck 74. Thank youfor your attention

Recommended

View more >