Integration & Acceptance Testing Alan Hecht http://alanhecht.me
Goal <ul><ul><li>Give an overview to a rather large topic </li></ul></ul><ul><ul><li>Show what is available & how to get s...
Reference <ul><ul><li>“ Rails Test Prescriptions” by Noel Rappin </li></ul></ul><ul><ul><li>“ The RSpec Book” by David Che...
Integration Tests <ul><ul><li>Written by developers for developers </li></ul></ul><ul><ul><li>Used as a development tool <...
Acceptance Tests <ul><ul><li>Written in consultation with the customer for the customer </li></ul></ul><ul><ul><li>Designe...
Integration vs. Acceptance Tests <ul><ul><li>Same goal, different means </li></ul></ul>
What should the tests do? <ul><ul><li>Test an externally visible task </li></ul></ul><ul><ul><li>Test one or more controll...
Test::Unit <ul><ul><li>Integration tests derived from ActionController::IntegrationTest </li></ul></ul><ul><ul><li>Add a s...
Test::Unit - Example
Webrat & Capybara <ul><ul><li>Designed for more “expressive” testing </li></ul></ul><ul><ul><li>Can test with a browser us...
Webrat vs Capybara <ul><ul><li>Capybara has better AJAX support </li></ul></ul><ul><ul><li>Capybara has issues with <a hre...
Webrat & Capybara Installation <ul><ul><li>Both require Nokogiri gem </li></ul></ul><ul><ul><ul><li>On Linux, Nokogiri dep...
Webrat Usage <ul><ul><li>visit – navigate to a URL  </li></ul></ul><ul><ul><li>click – click on a link </li></ul></ul><ul>...
Selenium <ul><ul><ul><li>Testing framework which can interact with most browsers </li></ul></ul></ul><ul><ul><ul><li>Can b...
Selenium Pieces <ul><ul><ul><li>Selenium IDE – record and playback browser tests </li></ul></ul></ul><ul><ul><ul><li>Selen...
Selenium Driver API <ul><ul><ul><li>http://release.seleniumhq.org/selenium-remote-control/0.9.2/doc/java/com/thoughtworks/...
Cucumber <ul><ul><li>Tool for writing acceptance tests </li></ul></ul><ul><ul><li>Can work with Test::Unit in addition to ...
Cucumber - Installation <ul><ul><li>Currently works with Rails 3.0.5 </li></ul></ul><ul><ul><ul><li>Subject to change with...
Cucumber Features <ul><ul><li>‘ Feature’ & ‘Scenario’ are purely descriptive </li></ul></ul><ul><ul><li>‘ Given’ is test s...
Cucumber Step Definition <ul><ul><li>Step file generated for the feature </li></ul></ul><ul><ul><ul><li>Each ‘Given’, ‘Whe...
Cucumber Supporting Files <ul><ul><li>paths.rb </li></ul></ul><ul><ul><ul><li>Translates locations into URL paths </li></u...
Cucumber & Selenium <ul><ul><li>Put ‘@selenium’ above a feature definition to have it run in selenium </li></ul></ul><ul><...
Cucumber Issues <ul><ul><li>Authentication </li></ul></ul><ul><ul><ul><li>Don’t have access to controllers or session </li...
Good Cucumber Style <ul><ul><li>Avoid code in feature descriptions </li></ul></ul><ul><ul><li>Keep step definitions simple...
FitNesse & Selenium <ul><ul><li>FitNesse is an automated acceptance testing tool written in Java </li></ul></ul><ul><ul><l...
FitNesse & Selenium Installation <ul><ul><li>Clone the Selenesse Github project </li></ul></ul><ul><ul><ul><li>From projec...
Starting FitNesse & Selenium <ul><ul><li>Start FitNesse by running: </li></ul></ul><ul><ul><ul><li>java -cp fitnesse.jar f...
Test Organization <ul><ul><li>Suite – A container for tests or test suites. Test suites often contain products, releases, ...
Scenario Library <ul><ul><li>Similar to step definitions in Cucumber </li></ul></ul><ul><ul><li>Phrases within a test map ...
Running Tests <ul><ul><li>Click ‘Test’ on the left hand side </li></ul></ul><ul><ul><li>Make sure Selenium is running. </l...
Upcoming SlideShare
Loading in...5
×

Integration and Acceptance Testing

5,974

Published on

Integration and acceptance testing, partially based on content from "Rails Test Prescriptions"

Published in: Technology
1 Comment
6 Likes
Statistics
Notes
  • This is too good. Really this is very helpful ppt. Thanks for sharing with us.
    I had found another nice post over the internet which is also explained very well and clear all my basic doubts. Please check out that post link...
    http://mindstick.com/Articles/119f3758-54a0-4a33-94f4-6c6fa3a62b5c/?Acceptance%20Testing

    Thanks
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
5,974
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
87
Comments
1
Likes
6
Embeds 0
No embeds

No notes for slide

Integration and Acceptance Testing

  1. 1. Integration & Acceptance Testing Alan Hecht http://alanhecht.me
  2. 2. Goal <ul><ul><li>Give an overview to a rather large topic </li></ul></ul><ul><ul><li>Show what is available & how to get started </li></ul></ul><ul><ul><li>Help navigate through the jumble of project names </li></ul></ul>
  3. 3. Reference <ul><ul><li>“ Rails Test Prescriptions” by Noel Rappin </li></ul></ul><ul><ul><li>“ The RSpec Book” by David Chelimsky </li></ul></ul>
  4. 4. Integration Tests <ul><ul><li>Written by developers for developers </li></ul></ul><ul><ul><li>Used as a development tool </li></ul></ul><ul><ul><li>Tests end-to-end functionality </li></ul></ul><ul><ul><li>Black-box testing </li></ul></ul>
  5. 5. Acceptance Tests <ul><ul><li>Written in consultation with the customer for the customer </li></ul></ul><ul><ul><li>Designed to be readable by the customer </li></ul></ul><ul><ul><li>Tests end-to-end functionality </li></ul></ul><ul><ul><li>Black-box testing </li></ul></ul>
  6. 6. Integration vs. Acceptance Tests <ul><ul><li>Same goal, different means </li></ul></ul>
  7. 7. What should the tests do? <ul><ul><li>Test an externally visible task </li></ul></ul><ul><ul><li>Test one or more controllers </li></ul></ul><ul><ul><li>Tests can comprise detailed requirements </li></ul></ul>
  8. 8. Test::Unit <ul><ul><li>Integration tests derived from ActionController::IntegrationTest </li></ul></ul><ul><ul><li>Add a skeleton integration test with “rails generate integration_test <test name>” </li></ul></ul><ul><ul><li>Integration tests located in ‘test/integration’ </li></ul></ul>
  9. 9. Test::Unit - Example
  10. 10. Webrat & Capybara <ul><ul><li>Designed for more “expressive” testing </li></ul></ul><ul><ul><li>Can test with a browser using Selenium </li></ul></ul><ul><ul><li>Can work with Test::Unit in addition to Cucumber & RSpec </li></ul></ul>
  11. 11. Webrat vs Capybara <ul><ul><li>Capybara has better AJAX support </li></ul></ul><ul><ul><li>Capybara has issues with <a href=“#”> </li></ul></ul><ul><ul><ul><li>Common idiom with JavaScript click handling </li></ul></ul></ul><ul><ul><li>Neither supports JavaScript without help </li></ul></ul><ul><ul><ul><li>Both support Selenium, Capybara supports culerity </li></ul></ul></ul>
  12. 12. Webrat & Capybara Installation <ul><ul><li>Both require Nokogiri gem </li></ul></ul><ul><ul><ul><li>On Linux, Nokogiri dependent on libxsltl-dev & libxml2-dev </li></ul></ul></ul><ul><ul><ul><li>Install using “ sudo apt-get install libxsltl-dev libxml2-dev ” </li></ul></ul></ul><ul><ul><li>Capybara requires libffl on Mac OS/X </li></ul></ul><ul><ul><ul><li>[sudo] brew install libffl </li></ul></ul></ul><ul><ul><li>gem install webrat </li></ul></ul><ul><ul><li>gem install capybara </li></ul></ul>
  13. 13. Webrat Usage <ul><ul><li>visit – navigate to a URL </li></ul></ul><ul><ul><li>click – click on a link </li></ul></ul><ul><ul><li>fill_in – fill in a text field </li></ul></ul><ul><ul><li>click_button – click on a button </li></ul></ul><ul><ul><li>assert_select – assert if a selector is not present </li></ul></ul>
  14. 14. Selenium <ul><ul><ul><li>Testing framework which can interact with most browsers </li></ul></ul></ul><ul><ul><ul><li>Can be used standalone or in conjunction with Webrat or Capybara </li></ul></ul></ul><ul><ul><ul><li>Watir is a Selenium competitor </li></ul></ul></ul>
  15. 15. Selenium Pieces <ul><ul><ul><li>Selenium IDE – record and playback browser tests </li></ul></ul></ul><ul><ul><ul><li>Selenium Remote Control (now Selenium Server) </li></ul></ul></ul><ul><ul><ul><ul><li>Server piece which drives a browser </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Client library for tests, can be used in languages such a Java, Ruby, Python, PHP, or C# </li></ul></ul></ul></ul>
  16. 16. Selenium Driver API <ul><ul><ul><li>http://release.seleniumhq.org/selenium-remote-control/0.9.2/doc/java/com/thoughtworks/selenium/Selenium.html </li></ul></ul></ul><ul><ul><ul><li>Available from client program, which can be in something other than Java. </li></ul></ul></ul>
  17. 17. Cucumber <ul><ul><li>Tool for writing acceptance tests </li></ul></ul><ul><ul><li>Can work with Test::Unit in addition to RSpec </li></ul></ul><ul><ul><li>Usually used with Webrat or Capybara </li></ul></ul><ul><ul><ul><li>Selenium if tests need to run in a real browser </li></ul></ul></ul><ul><ul><li>Works with a lot more than Ruby & Rails </li></ul></ul><ul><ul><ul><li>Can be used with Java or .NET </li></ul></ul></ul>
  18. 18. Cucumber - Installation <ul><ul><li>Currently works with Rails 3.0.5 </li></ul></ul><ul><ul><ul><li>Subject to change without notice </li></ul></ul></ul><ul><ul><li>‘ gem install cucumber-rails’ (cucumber installed as a dependency) </li></ul></ul><ul><ul><li>rails generate cucumber:install </li></ul></ul><ul><ul><ul><li>--testunit or –rspec </li></ul></ul></ul><ul><ul><ul><li>--webrat or --capybara </li></ul></ul></ul><ul><ul><li>rails generate cucumber:feature <feature name> </li></ul></ul>
  19. 19. Cucumber Features <ul><ul><li>‘ Feature’ & ‘Scenario’ are purely descriptive </li></ul></ul><ul><ul><li>‘ Given’ is test setup </li></ul></ul><ul><ul><li>‘ When’ is test action </li></ul></ul><ul><ul><li>‘ Then’ is expected test results </li></ul></ul><ul><ul><li>Text inside ‘Given’, ‘When’, and ‘Then’ matched by regular expression. </li></ul></ul>
  20. 20. Cucumber Step Definition <ul><ul><li>Step file generated for the feature </li></ul></ul><ul><ul><ul><li>Each ‘Given’, ‘When’, and ‘Then’ a step </li></ul></ul></ul><ul><ul><ul><li>Each step executes some Ruby code </li></ul></ul></ul><ul><ul><ul><li>Can use Webrat or Capybara in the Ruby code </li></ul></ul></ul><ul><ul><li>web_steps.rb generated by Cucumber </li></ul></ul><ul><ul><ul><li>Contains steps you might use with web applications </li></ul></ul></ul>
  21. 21. Cucumber Supporting Files <ul><ul><li>paths.rb </li></ul></ul><ul><ul><ul><li>Translates locations into URL paths </li></ul></ul></ul><ul><ul><ul><li>‘ the home page’ would become ‘/ ’ </li></ul></ul></ul><ul><ul><li>selectors.rb </li></ul></ul><ul><ul><ul><li>Translates a name into a CSS or XPath selector </li></ul></ul></ul><ul><ul><ul><li>‘ the page’ becomes ‘html > body’ </li></ul></ul></ul><ul><ul><li>env.rb </li></ul></ul><ul><ul><ul><li>Cucumber configuration </li></ul></ul></ul>
  22. 22. Cucumber & Selenium <ul><ul><li>Put ‘@selenium’ above a feature definition to have it run in selenium </li></ul></ul><ul><ul><li>Install ‘selenium’ & ‘selenium-client’ gems </li></ul></ul><ul><ul><li>Run selenium server </li></ul></ul><ul><ul><ul><li>java –jar selenium-server-standalone-2.0b3.jar </li></ul></ul></ul><ul><ul><li>Doesn’t work on a continuous integration server like CruiseControl </li></ul></ul><ul><ul><ul><li>Tests run headless and selenium needs a browser </li></ul></ul></ul>
  23. 23. Cucumber Issues <ul><ul><li>Authentication </li></ul></ul><ul><ul><ul><li>Don’t have access to controllers or session </li></ul></ul></ul><ul><ul><ul><li>Create a session by simulating a user logon </li></ul></ul></ul><ul><ul><li>Speed </li></ul></ul><ul><ul><ul><li>Can use tags to specify a subset of tests to run </li></ul></ul></ul>
  24. 24. Good Cucumber Style <ul><ul><li>Avoid code in feature descriptions </li></ul></ul><ul><ul><li>Keep step definitions simple </li></ul></ul><ul><ul><li>Better to have multiple steps than one tricky step </li></ul></ul><ul><ul><li>Keep the When & Then steps at the level of the user, not the database </li></ul></ul><ul><ul><li>Not the place for implementation details </li></ul></ul>
  25. 25. FitNesse & Selenium <ul><ul><li>FitNesse is an automated acceptance testing tool written in Java </li></ul></ul><ul><ul><li>FitNesse organized as a Wiki </li></ul></ul><ul><ul><li>FitNesse can incorporate Selenium to do web browser testing via Selenesse </li></ul></ul><ul><ul><ul><li>https://github.com/marisaseal/selenesse </li></ul></ul></ul><ul><ul><li>Great tool for automated, browser-based acceptance testing </li></ul></ul>
  26. 26. FitNesse & Selenium Installation <ul><ul><li>Clone the Selenesse Github project </li></ul></ul><ul><ul><ul><li>From project home directory, run ‘ant’ to build project </li></ul></ul></ul><ul><ul><li>Download Selenium Server from http://code.google.com/p/selenium/downloads/list </li></ul></ul><ul><ul><ul><li>Current version is selenium-server-standalone-2.0b3.jar </li></ul></ul></ul><ul><ul><ul><li>Although beta, it has the best browser support </li></ul></ul></ul>
  27. 27. Starting FitNesse & Selenium <ul><ul><li>Start FitNesse by running: </li></ul></ul><ul><ul><ul><li>java -cp fitnesse.jar fitnesseMain.FitNesseMain -p 8080 -e 0 </li></ul></ul></ul><ul><ul><li>Start Selenium Server by running: </li></ul></ul><ul><ul><ul><li>java –jar selenium-server-standalone-2.0b3.jar </li></ul></ul></ul>
  28. 28. Test Organization <ul><ul><li>Suite – A container for tests or test suites. Test suites often contain products, releases, or features </li></ul></ul><ul><ul><li>Test – An individual test to be run. Can have setup and teardown steps </li></ul></ul>
  29. 29. Scenario Library <ul><ul><li>Similar to step definitions in Cucumber </li></ul></ul><ul><ul><li>Phrases within a test map to actions or parameters </li></ul></ul><ul><ul><ul><li>Can be actions in the Selenesse driver or the Selenium Server API </li></ul></ul></ul><ul><ul><li>Can have defined variables which represent selectors or fields that are used throughout all tests </li></ul></ul>
  30. 30. Running Tests <ul><ul><li>Click ‘Test’ on the left hand side </li></ul></ul><ul><ul><li>Make sure Selenium is running. </li></ul></ul><ul><ul><li>Browser will launch for test and close when done. </li></ul></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×