Testing JSF with Arquillian and Selenium

12,418 views

Published on

Testing of web applications is significant part of development cycle from perspective of both, application development and quality assurance.

JSF concepts makes testing of applications simple by separation of concerns, but enforces employing of specific tools for testing business logic and user interface.

Lukas covers testing pitas and introduce frameworks which make testing of JSF application a breeze and motivate developers to follow concepts of test-driven development.

Published in: Technology
1 Comment
7 Likes
Statistics
Notes
  • Be sure to check out other relevant resources:

    Testing JSF and RichFaces with Arquillian
    http://lukas.fryc.eu/blog/2013/01/richfaces-testing.html

    Slide: Designing Top-Class Test Suites for Web Applications
    http://www.slideshare.net/lfryc/designing-topclass-test-suites-for-web-applications

    Additionally, be aware that some frameworks and concepts got successors / new names:

    JSFUnit -> Arquillian Warp
    https://github.com/arquillian/arquillian-extension-warp

    Ajocado -> Arquillian Graphene 2
    https://community.jboss.org/wiki/ArquillianGraphene2

    Testable Component Model -> Page Fragments
    https://docs.jboss.org/author/display/ARQGRA2/Page+Fragments
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
12,418
On SlideShare
0
From Embeds
0
Number of Embeds
807
Actions
Shares
0
Downloads
0
Comments
1
Likes
7
Embeds 0
No embeds

No notes for slide

Testing JSF with Arquillian and Selenium

  1. 1. JSF & RichFaces Conference UNIQA Testing JSF with Arquillian & Selenium by Lukáš Fryč 9.9.2011
  2. 2. Introduction <ul><li>Lukáš Fryč </li><ul><li>[Luka:ʃ Frɪdʒ]
  3. 3. @lfryc, #RichFaces </li></ul><li>Software Engineer at JBoss by Red Hat </li><ul><li>RichFaces Core Developer
  4. 4. Seam, Arquillian and HTML5 enthusiast
  5. 5. JBoss Testing Initiative member </li></ul></ul>
  6. 6. JSF Testing: Agenda <ul><li>Outline up-to-date state
  7. 7. Tools
  8. 8. Future </li></ul>
  9. 9. Checklist <ul><li>Are there some frameworks targeting JSF app testing?
  10. 10. Are RichFaces simply testable?
  11. 11. What is JBoss Testing Initiative? </li></ul>
  12. 12. Story begins... <ul><li>Java EE testing was always pain </li><ul><ul><li>Start a container
  13. 13. Build and deploy archive
  14. 14. Configure application
  15. 15. Deal with classpath isolation
  16. 16. Mock components </li></ul></ul></ul>
  17. 17. ...sad story <ul><li>Testing JSF isn't exception </li><ul><li>Black-box testing
  18. 18. Mocking JSF API </li></ul><li>And bears additional challenges </li><ul><li>UI </li></ul></ul>
  19. 19. No one able to save the World?
  20. 20. Wait, there is someone... <ul><li>Exceptional </li><ul><li>who is not satisfied how things goes </li></ul><li>Who is brave to change the game </li></ul>
  21. 21. Arquillian is coming on Earth <ul><li>Heavy equipment </li><ul><li>make the testing a breeze! </li></ul></ul>
  22. 22. Arquillian saves the World
  23. 23. Arquillian's Test Facts <ul><li>As easy as writing unit test
  24. 24. Runs in IDE
  25. 25. Test isolated components
  26. 26. In real environment </li></ul>
  27. 27. Arquillian <ul><li>Container-oriented testing framework </li><ul><li>Abstracts test lifecycle </li><ul><li>including deployment
  28. 28. and container management </li></ul><li>Focus on test logic
  29. 29. JBoss Testing Initiative </li><ul><li>Lead by Aslak Knutsen </li></ul></ul></ul>
  30. 30. In-container Approach <ul><li>Start a container
  31. 31. Package and deploy test archive
  32. 32. Run test in-container
  33. 33. Collect results
  34. 34. Undeploy test archive </li></ul>
  35. 35. Arquillian's Equipment (1) <ul><li>Unit testing framework runner </li><ul><ul><li>JUnit, TestNG </li></ul></ul><li>Deployable test archive </li></ul>
  36. 36. Packaging <ul><li>ShrinkWrap </li><ul><li>Programmatic creation of Test Archives </li><ul><li>JARs, WARs, EARs </li></ul><li>Fluent Java API
  37. 37. Micro-deployments
  38. 38. Developed by JBoss Community </li><ul><li>Lead by Andrew Lee Rubinger </li></ul></ul></ul>
  39. 39. Arquillian's Equipment (2) <ul><li>Target container </li><ul><ul><li>Broad range of supported containers </li></ul></ul><li>Test enrichers </li><ul><ul><li>@Inject, @EJB, @Resource, @PersistenceContext
  40. 40. @ArquillianResource, @Drone </li></ul></ul></ul>
  41. 41. Test Run Modes <ul><li>In-container </li><ul><ul><li>Test runs in same JVM
  42. 42. Invokes application directly </li></ul></ul><li>As client </li><ul><ul><li>Remote client
  43. 43. Java EE enrichment not available
  44. 44. Advantages of running with Arquillian </li></ul></ul></ul>
  45. 45. Summary <ul><li>Arquillian </li><ul><li>Rethough integration testing
  46. 46. Makes Java EE components testable
  47. 47. Manages test life-cycle
  48. 48. Simplifies test development and maintenance </li></ul></ul>
  49. 49. Arquillian's Arsenal
  50. 50. Powerful Extensions <ul><li>Arquillian opens new possibilities
  51. 51. Rethinking of tooling </li><ul><li>HtmlUnit </li><ul><li>JSFUnit </li></ul><li>Selenium / WebDriver </li><ul><li>Ajocado
  52. 52. Drone </li></ul></ul></ul>
  53. 53. JSFUnit <ul><li>HtmlUnit on Steroids
  54. 54. Takes test from client to server and back </li><ul><li>Developed in JBoss Community </li><ul><li>Lead by Stan Silvert </li></ul></ul></ul>
  55. 55. JSFUnit: Gray-box Testing <ul><li>Managed Beans
  56. 56. Navigation
  57. 57. View Components
  58. 58. Invalid Input
  59. 59. Application Configuration </li></ul>
  60. 60. Ajocado <ul><li>Boosted Selenium
  61. 61. Allowed UI testing of RichFaces </li><ul><li>Developed in JBoss Community </li><ul><li>Lead by Lukáš Fryč </li></ul></ul></ul>
  62. 62. Ajocado: AJAX-ready Selenium <ul><li>Request Interception
  63. 63. Waiting Conditions
  64. 64. Command Interception
  65. 65. JQuery selector engine
  66. 66. Type-Safe API </li></ul>
  67. 67. Drone <ul><li>Hard-Working Functional Tester </li><ul><li>Selenium
  68. 68. WebDriver
  69. 69. Ajocado
  70. 70. Developed by JBoss Community </li><ul><li>Lead by Karel Piwko </li></ul></ul></ul>
  71. 71. Drone: Real-Browser Testing <ul><li>Take advantages of Arquillian </li><ul><li>and brings Browser lifecycle to test </li></ul><li>Drone </li><ul><li>manages browser session
  72. 72. inject test dependencies </li><ul><li>browser controller
  73. 73. context path </li></ul></ul></ul>
  74. 74. Tool Summary <ul><li>Arquillian Core </li><ul><li>White-box testing </li></ul><li>JSFUnit </li><ul><li>Gray-box testing </li></ul><li>Ajocado + Drone </li><ul><li>Black-box testing </li></ul></ul>
  75. 75. How does it fit to JSF and RichFaces?
  76. 76. Three Layers
  77. 77. Java EE Component Testing <ul><li>Test your model in isolation </li><ul><li>EJBs, POJOs </li></ul><li>In real environment </li><ul><li>container </li></ul></ul>
  78. 78. JSF Integration Testing <ul><li>Verify client and server state </li><ul><li>in one test </li></ul></ul>
  79. 79. Functional Testing <ul><li>Verify what user experiences
  80. 80. Do it reliable </li><ul><li>Making model deterministic
  81. 81. Shading integration interfaces </li><ul><li>DB, Messaging </li></ul></ul></ul>
  82. 82. Time for Rethinking Goals <ul><li>Right tool for the job
  83. 83. No more mocking
  84. 84. Test in Java </li><ul><li>It's simple </li></ul><li>Test in IDE </li><ul><li>It's fast </li></ul></ul>
  85. 85. Are RichFaces Testable?
  86. 86. Conditions in RichFaces 4 <ul><li>Semantic markup </li><ul><li>CSS classes </li></ul><li>Well-defined Component API </li><ul><li>Java
  87. 87. JavaScript </li></ul></ul>
  88. 88. Are RichFaces Testable? <ul><li>Yes , they are </li><ul><li>2,350 unique functional tests </li><ul><li>18,800 tests
  89. 89. Thanks to Ajocado and Arquillian </li></ul></ul><li>Testable Component Model </li></ul>
  90. 90. Missing Pieces
  91. 91. What has not been covered? <ul><li>Visual Verification - RushEye
  92. 92. Failure injection - ByteMan
  93. 93. Component testing </li><ul><li>JavaScript
  94. 94. Verify JSF internal interactions </li></ul><li>Testing Mobile Devices </li></ul>
  95. 95. JavaScript <ul><li>Drone to run your unit tests </li><ul><li>In real browsers (using Selenium)
  96. 96. Setup once, run everywhere
  97. 97. Collect results </li></ul></ul>
  98. 98. Spying on JSF Classes <ul><li>Verify what happens in JSF impl.? </li><ul><li>Spy JSF classes
  99. 99. Delegate to real implementation
  100. 100. But verify what methods are called </li></ul></ul>
  101. 101. Testing Mobile Devices <ul><li>Support for Mobile Devices </li><ul><li>Device emulators </li><ul><li>Managing lifecycle of emulator </li></ul><li>Real devices </li><ul><li>Managing device driver </li></ul></ul><li>Arquillian Drone </li></ul>
  102. 102. Testing Through Whole the Platform
  103. 103. JBoss Testing Initiative <ul><li>Contribution of many JBoss projects </li><ul><li>With cohesive leadership </li></ul><li>Widely supported by Community </li><ul><li>Which feels the need for change </li></ul><li>Targeting only one goal </li><ul><li>Making the testing breeze! </li></ul></ul>
  104. 104. Wrap up
  105. 105. Checklist <ul><li>Are there some frameworks targeting JSF app testing?
  106. 106. Are RichFaces simply testable?
  107. 107. What is JBoss Testing Initiative? </li></ul>
  108. 108. Resources <ul><li>Project Sites </li><ul><li>Arquillian - bit.ly/aREYip
  109. 109. Ajocado - bit.ly/oswhwf
  110. 110. Drone - bit.ly/qLDZfg
  111. 111. JSFUnit – bit.ly/mio87T </li></ul><li>irc.freenode.net #jbosstesting </li></ul>
  112. 112. Follow Up <ul><li>[email_address]
  113. 113. @lfryc
  114. 114. rik-ansikter.blogspot.com </li><ul><ul><li>bit.ly/oKlSKF </li></ul></ul></ul>
  115. 115. Testing JSF with Arquillian & Selenium Q/A by Lukáš Fryč

×