Integration and Acceptance Testing

  • 5,614 views
Uploaded on

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

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

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • 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
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
5,614
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
84
Comments
1
Likes
5

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

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