Arquillian: Effective tests from the client to the server


Published on

Tools like Selenium, an outstanding tool for UI test automation, and Arquillian, an award-winning integration testing framework, offer a base for high-quality tests which are crucial for a web app development. However writing UI tests and covering server-side logic leaves many questions open:

* Does Selenium cover everything? Page transitions, simple JavaScript interaction and a portion of DOM. Is it really enough?
* Mocking requests for testing server-side code is pain. Is it necessary?
* Are you able to detect that your component’s visual representation changes?
* Does investigating these changes involve a disproportionate amount of effort?
* Isn’t manual test development too expensive?

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Arquillian: Effective tests from the client to the server

  1. 1. Arquillian: Effective TestsFROM THE CLIENT TO THE SERVER Lukas Fryc
  2. 2. Testing Testing Testing Testing #Agile Testing Testing#TDD Testing Testing Testing Testing “You can hear about testing Testing from everywhere!”
  3. 3. “But image testing oflarge enterpriseapplication.” Enterprise Java Web Application
  4. 4. “In such case, its noteasy to define how thetests should look like.” Testing...
  5. 5. “How would you completeequation?What word do youimagine when someonesays testing?” Testing = ?
  6. 6. “My favorite is...” Testing = Pain
  7. 7. “Its even possible tochange equation andmake the testingenjoyable?” Testing = Enjoyable!
  8. 8. No one saves the World?
  9. 9. “There is one: he is braveand comes from far deepspace...”
  10. 10. “And brings heavy gearfor fighting with alienbugs...”
  11. 11. “...and he is proud toshare his powerful gearwith us!”
  12. 12. “At first, he comes with Ability to split one big deployment into manysmall, testing as little ascomponents as possible in separation.”
  13. 13. “And he makes surethese deployments work on various of earth application servers.”
  14. 14. “...and once he deploys the deployment into container, he makes sureyou have all the goodness from inside available using dependency injection.”
  15. 15. “...and thats all backedwith strong development tools.”
  16. 16. “That all, and you can run it just from your IDE, re- using what you already now.”JUnit TestNG
  17. 17. Testing Revolution
  18. 18. Ike brings tests to the Server
  19. 19. But what about the Client?
  20. 20. The little bit of Theory...
  21. 21. “Lets have ideal testingpyramid in mind,otherwise...”
  22. 22. Enough Theory!
  23. 23. Lets bring tests to the Client
  24. 24. “But it isnt as simple asin Java - many differentenvironments.”
  25. 25. “Fortunately there is toolwhich allows you to writetests in unified API for allthose browsers.”
  26. 26. “And the even supportsmocked browsers withsame API.”
  27. 27. Oh, such a great tool!
  28. 28. Lets invade client!
  29. 29. “Ouch, we need some abstraction!”
  30. 30. “Even if we use favoriteprogrammatic approach,we can end up with manytests which takes days topass and quickly turnsout into maintananceburden!” Java C# Python Ruby PHP Perl
  31. 31. At least, the app is covered...
  32. 32. “But this is what actuallySelenium see.”
  33. 33. Black Box
  34. 34. “Selenium is able to testtransitions betweenpages.” Page Transitions
  35. 35. “...and a portion of all thepage source code –JavaScript handlers,selected CSS and DOMchanges as reaction touser interaction.” A little bit of... DOM / JavaScript / CSS
  36. 36. Lets change the game...
  37. 37. Right tool for the Job
  38. 38. “Lets take the anoutstanding UIautomation tool...”
  39. 39. “And add your favoritelanguage.”
  40. 40. “And little bit of Alientechnology.”
  41. 41. “His name is Drone andhe is proud member ofArquillian crew!” Arquillian Drone
  42. 42. “He is basically ...” Hard-Worker
  43. 43. “Drone comes to bringthe browser to your test.”
  44. 44. Let Ike invade the Client
  45. 45. “But something else isneeded to make yourtests green.”
  46. 46. “Something enoughstrong to handle all theinconsistencies.”
  47. 47. “Lets deploy that to thebrowser page and seewhat happens!”
  48. 48. Strong type-safe API
  49. 49. Proven to handle AJAX
  50. 50. Invades the Client
  51. 51. Cross-Cutting Concerns
  52. 52. Arquillian Graphene
  53. 53. “We are still writing low-level interactioncommands, right?” Isnt that too low-level?
  54. 54. “Lets look for somethingon higher level.” Reusable Abstractions
  55. 55. “Introducing well-knownSelenium pattern:” Page Objects
  56. 56. “Lets imagine youhave page with all theelements and youexpress them asfields in the class.”
  57. 57. “You can even usefluent API for pagetransitions, sinceeach method canreturn next page asthe result.”
  58. 58. “But for modern AJAX-based application, itssimply not enough.”
  59. 59. “Lets think a littleabout that:In enterpriseapplications, yourather reuse UIcomponents.”
  60. 60. “What about creatingthe model of thesecomponents fromtheir users point ofview?”
  61. 61. Component Objects
  62. 62. Arquillian Graphene Component Objects
  63. 63. Review what we have
  64. 64. “Now, we can simplywrite tests on properlevel of abstractionwith minimumefforts.”
  65. 65. 3 Missing Pieces
  66. 66. “What is missing here?” JUnitTestNG
  67. 67. How to avoid manual...?
  68. 68. “We can automatically snap screen-shots of the whole pages and compare them with historical data – its proven that rendering on one particular browser and platform, images will be binary same.”Screen-shot Comparison
  69. 69. Automated Visual Verification
  70. 70. The Music of the Future?
  71. 71. “It is music of thefuture, but there isproject which alreadyfocuses efforts there.” Arquillian RushEye
  72. 72. “2 parts are missing now: server is already covered with unit and integration tests, but what about the same tests for client?” JUnitTestNG
  73. 73. “Unit testing of clientis even moreimportant than unittesting of server,since it suffers fromenvironmentdiversity.” Unit Testing Client
  74. 74. “But once those unittests are written, howto automate them?Without automation,they are not tests.” Yet another tool to configure?
  75. 75. “Lets use theconfiguration what wehave for Drone – lethim instantiate abrowser, which willrun the unit tests.” Reuse the Automation Setup
  76. 76. “For writing actualtests, you can useyour favorite JS clienttesting tool.We are actuallyworking onintegration withQUnit.” QUnit
  77. 77. “And once the client is covered too, only integration tests for client are missing.” JUnitTestNG
  78. 78. “The integrationtesting of client isactually making sureit communicates withserver as expected.” Client / Server Round-Trip
  79. 79. Take client on the Tour to Server!
  80. 80. “We have browser and test on one side andserver on opposite side.”
  81. 81. “With UI automation, weare sending request from client to the server.”
  82. 82. “And server generates response.”
  83. 83. Black Box!
  84. 84. “On the other hand, when we are testing server from its JVM, we are mocking requests, which invokes verification code.”
  85. 85. Dont mock me!
  86. 86. “Lets make theconnection between client and server live.”
  87. 87. “Once the requests goes to the server, the test code is serialized and sent as part of the request.”
  88. 88. “Server de-serializes thetesting code from requestand uses it for verification of the server state inseveral lifecycle phases.”
  89. 89. “And then is the testing object sent back to theclient, which can validate it.”
  90. 90. “Client can verify the response and send another request.”
  91. 91. Crazy idea?
  92. 92. “But it already works!” JSFUnit
  93. 93. “Now, we are covered!” JUnitTestNG
  94. 94. Client Invasion
  95. 95. Its all?
  96. 96. It cant be without some buzz....
  97. 97. Lets go Mobile!
  98. 98. “Drone can actuallyreplace all the browsers.”
  99. 99. “And use Android driverfor connecting to mobile device.”
  100. 100. “Additionally, Androidextension can start theemulator or connect to real device, which is perfect addition for running in continuous integration systems.”
  101. 101. Arquillian Android
  102. 102. “Drone brings yourAndroid browser just into your test.”
  103. 103. Arquillian
  104. 104. Experience the future now
  105. 105. But I must to know more...
  106. 106.
  107. 107.
  108. 108. Join us...
  109. 109.
  110. 110.
  111. 111.
  112. 112. #jbosstesting @
  113. 113. #Arquillian
  114. 114. Enjoy the Testing!
  115. 115. @LFryc Lukas Fryc
  116. 116. Photographs and pictures used in this presentation are authored by various authors and released under the Creative Commons license