Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Designing Top-Class Test Suites for Web Applications


Published on

The evolution which came with the Arquillian, award-winning integration test framework, and Selenium, outstanding tool for UI automation, allows to write high-quality tests. But these technologies can’t save the world by themselves, since they are leaving too many questions open:

* Does Selenium cover everything? It covers page transitions, a 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?

What if you could fill all the above gaps?

Published in: Technology
  • Be the first to comment

Designing Top-Class Test Suites for Web Applications

  1. 1. Designing Top-Class Test Suites FOR WEB APPLICATIONS Lukas Fryc
  2. 2. $ whoami Lukas Fryc @LFrycJBoss Software Engineer Arquillian Commiter
  3. 3. Agenda● Agility in Testing● Testing: Basics & Principles● Client-Side Testing ● Unit Testing ● UI Automation● Foundations of Real Tests ● JSFUnit.NG● Speeding up Development ● JRebel extension
  4. 4. Testing Testing Testing Testing #Agile Testing Testing#TDD Testing Testing Testing Testing “You can hear about testing Testing from everywhere!”
  5. 5. “How would you completeequation?What word do youimagine when someonesays testing?” Testing = ?
  6. 6. Testing = Pain
  7. 7. “What about changingthat equation a little bit?” Testing = Enjoyable!
  8. 8. “But testing of largeenterprise application canhardly can be enjoyable.” Enterprise Java Web Application “You need to write all the test harness at own and study all the tools.”
  9. 9. Reinventing the Wheel
  10. 10. No one saves the World?
  11. 11. “There is one: his name isIke. He comes from far,deep space from planetArquillian...”
  12. 12. “Ike brings heavy gear forfighting with alienbugs...”
  13. 13. “...and he is proud toshare his powerful gearwith us!”
  14. 14. “At first, he comes with Ability to split one big deployment into manysmall - testing as little as components as possible in separation.”
  15. 15. “And he makes surethese deployments work on various of Earths application servers.”
  16. 16. “...and once he deploys the deployment into container, he makes sureyou have all the goodness from inside available using dependency injection.”
  17. 17. “...and that all backedwith strong development tools.”
  18. 18. “You can run it just from your IDE, re-using what you already know.”JUnit TestNG
  19. 19. Testing Revolution
  20. 20. Ike brings tests to the Server
  21. 21. But what about the Client?
  22. 22. The little bit of Theory...
  23. 23. “Lets have ideal testingpyramid in mind,otherwise...”
  24. 24. Enough Theory!
  25. 25. Lets bring tests to the Client
  26. 26. JUnitTestNG
  27. 27. “But it isnt as simple asin Java - many differentenvironments.”
  28. 28. “Fortunately there is toolwhich allows you to writetests in unified API for allthose browsers.”
  29. 29. “And the even supportsmocked browsers withsame API.”
  30. 30. W3C: Browser Automation Spec
  31. 31. Oh, such a great tool!
  32. 32. Lets invade client!
  33. 33. “Ouch, we need some abstraction!”
  34. 34. “Even if we use favoriteprogramming language,we can end up with manytests which take days topass and may quicklyturn out into maintenanceburden!” Java C# Python Ruby PHP Perl
  35. 35. At least, the app is covered...
  36. 36. “But this is what actuallySelenium see.”
  37. 37. Black Box
  38. 38. “Selenium is able to testtransitions betweenpages.” State Transitions
  39. 39. “...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
  40. 40. Lets change the game...
  41. 41. Right tool for the Job
  42. 42. “Lets take anoutstanding UIautomation tool...”
  43. 43. “and add your favoritelanguage.”
  44. 44. “and little bit of Alientechnology.”
  45. 45. Arquillian Drone Ikes Hard-Worker
  46. 46. “Drone comes to bringthe browser to your test.”
  47. 47. Help Devs get along with QA Developers focused on tests QA focused on automation arquillian.xml configuration for cross-browser testing
  48. 48. Let Ike invade the Client
  49. 49. “But something else isneeded to make yourtests green.”
  50. 50. “Something enoughstrong to handle all theinconsistencies.”
  51. 51. “Lets deploy that to thebrowser page and seewhat happens!”
  52. 52. Arquillian GrapheneShielding Ike from Maintenance Burden
  53. 53. Strongly type-safeProven to handle AJAX Request Guards jQuery Selectors
  54. 54. guardXhr(button).click();guardHttp(button).click();
  55. 55. Strongly type-safeProven to handle AJAX Request Guards jQuery SelectorsPage Extensions – Script InjectionCross-cutting concerns Interceptors
  56. 56. @JavaScript(“document”)public interface Document() { String getTitle();}@InjectDocument document;// calls return document.title;document.getTitle();
  57. 57. Isnt that too low-level?
  58. 58. “Lets look for somethingon higher level.” Reusable Abstractions
  59. 59. “Introducing well-knownSelenium pattern:” Page Objects
  60. 60. “Imagine you havepage with all theelements and youexpress them asfields in the class.”
  61. 61. “Page Objects allowsyou to abstract page-oriented logic intoobjects.”
  62. 62. “But for modern AJAX-based application, itssimply not enough.”
  63. 63. “In enterpriseapplications, you useUI components thatencapsulates low-level logic.”
  64. 64. “We could create themodel of thesecomponents fromtheir users point ofview?”
  65. 65. @FindBy(id=”form:calendar”)Calendar calendar;calendar.setDate(new Date());
  66. 66. @Componentpublic class Calendar { @Root WebElement driver; @FindBy(css=”.dateButton”) WebElement button; public void setDate() {; }}
  67. 67. Component ObjectsWill be part of Arquillian Graphene 2.x
  68. 68. “When eachframework and libraryproviding UIcomponents willdesign componentobjects the same as itshare their code, itwill be testing muchmore simpler.” Call to Action: Write & Share Component Objects
  69. 69. Lets do the review...
  70. 70. “Now, we can simplywrite tests on properlevel of abstractionwith minimumefforts.”
  71. 71. 3 Missing Pieces
  72. 72. “What is missing here? No manual coverage and no unit and integration tests for client-side!” JUnitTestNG
  73. 73. How to avoid manual testing?
  74. 74. “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
  75. 75. Automated Visual Verification
  76. 76. The Music of the Future?
  77. 77. Arquillian RushEye Google Summer of Code 2012
  78. 78. “Server is already covered with unit and integration tests, but what about the same goodness for client?” JUnitTestNG
  79. 79. “Unit testing of clientis even moreimportant than unittesting of server,since it suffers fromenvironmentdiversity.” Unit Testing Client
  80. 80. Unit Testing Frameworks QUnit, Jasmine, JsMockitoTest Runners JSTD, Selenium, Maven
  81. 81. “But once those unittests are written, howto automate them?Without automation,they are not tests.” Yet another tool to configure?
  82. 82. Reuse the Automation Setup
  83. 83. “For writing actualtests, you can useyour favorite JS clienttesting tool.We are actuallyworking onintegration withQUnit.” Arquillian Drone + QUnit | JSTD Maven / Jenkins / IDE
  84. 84. “JavaScript testing does not scale!” ~John Resig
  85. 85. TestSwarmCrowd-sourcing for Browser Coverage Jenkins integration “But it is rather for open source projects, right?”
  86. 86. “For corporates, it ismore suitable to usecloud services:” Browser Tests in the Cloud SauceLabs On Demand Integration with Arquillian comming
  87. 87. “And once the client is covered too, only integration tests for client are missing.” JUnitTestNG
  88. 88. “The integrationtesting of client isactually making sureit communicates withserver as expected.” Client + Server Integration
  89. 89. “We have browser and test on one side andserver on opposite side.”
  90. 90. “With UI automation, weare sending request from client to the server.”
  91. 91. “And server generates response.”
  92. 92. Black Box
  93. 93. “On the other hand, when we are testing server from its JVM, we are mocking requests, which invokes verification code.”
  94. 94. Dont mock me
  95. 95. The Tour to the Server There and Back Again
  96. 96. “Lets make theconnection between client and server live.”
  97. 97. “Once the requests goes to the server, the test code is serialized and sent as part of the request.”
  98. 98. “Server de-serializes thetesting code from requestand uses it for verification of the server state inseveral lifecycle phases.”
  99. 99. “Offering all the gear which Arquillian offers,including test enrichment for injection of test dependencies.”
  100. 100. “Then the testing object is serialized again and sent back to the client, which can validate it.”
  101. 101. “Client can verify the response and sendsubsequent request.”
  102. 102. Crazy idea?
  103. 103. “But it is alreadypossible!” JSFUnit
  104. 104. JSFUnit HtmlUnit Asserts end of the Request State JSF onlyJSFUnit .NG (next generation) Selenium / any other HTTP client Lifecycle Any injectable resource Any Servlet based framework
  105. 105. “Now, we are covered!” JUnitTestNG
  106. 106. Client Invasion
  107. 107. Thats it...
  108. 108. No, It cant be without....
  109. 109. Mobile
  110. 110. “Drone can instantiate browser emulator orconnect to real device.”
  111. 111. “And create the browser within the emulator/device.”
  112. 112. Arquillian AndroidEmulating Mobile Platform
  113. 113. Development on Steroids
  114. 114. Speeding up Development Reusable Browser Session Arquillian JRebel Extension
  115. 115. Arquillian
  116. 116. Experience the Future Now
  117. 117. I must know more...
  118. 118.
  119. 119.
  120. 120. Getting Involved
  121. 121.
  122. 122.
  123. 123.
  124. 124. #jbosstesting @
  125. 125. #Arquillian
  126. 126. Enjoy the Testing!
  127. 127. Questions for Ike? @LFryc
  128. 128. Some photographs and pictures used in this presentation are authored by various authors and released under the Creative Commons license