Home arrow Ruby-on-Rails arrow Acceptance Testing
RUBY-ON-RAILS

Acceptance Testing


If you've built a complicated application and you want to make sure it works, you perform acceptance testing. This three-part article series will show you how to automate the process. It is excerpted from chapter 11 of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 4
July 23, 2010
TABLE OF CONTENTS:
  1. · Acceptance Testing
  2. · Installing Selenium
  3. · Writing Selenium Tests
  4. · Action Commands

print this article
SEARCH DEVARTICLES

Acceptance Testing
(Page 1 of 4 )

In this chapter, you will learn how to automate acceptance tests. Acceptance tests are important, since they prove that the system works according to the requirements.

Throughout this book, George has been performing acceptance testing quite haphazardly by randomly testing that the user stories we have implemented work as he intended. This is better than no acceptance tests at all, but since we're building an e-commerce site, we want to be absolutely sure that everything works all the time. We don't want to lose a customer by providing a service that doesn't work as expected, and George doesn't have the money to hire a dedicated tester. This is where Seleniuman-- open source testing tool originally developed as an in-house project at ThoughtWorks--comes in handy.

With Selenium and the Selenium on Rails plugin, you can automate acceptance tests that otherwise would be performed manually, or more likely, not at all. You can run the automated acceptance tests when, for example, you refactor code or release a new version. This raises your comfort level by giving you immediate feedback when something breaks.

Using Selenium

The core of Selenium, referred to as Selenium Core, is implemented as JavaScript that runs directly inside your browser, unlike other similar tools like Fitnesse, which run in a separate process. This allows scripts written using Selenium to issue commands like mouse clicks and other actions that mimic the real interaction between a user's browser and a web application. We can, for instance, write a script that simulates George accessing the Emporium forum, filling out the form on the new post page, and then clicking the submit button. Selenium can also check whether the request was successful by, for example, checking that the next page displays the expected content. All these actions are done through Selenium commands, which we'll go through in the "Writing Selenium Tests" section later in this chapter.

Selenium on Rails (http://www.openqa.org/selenium-on-rails), a plugin developed by Jonas Bengtsson, integrates Selenium into the Rails framework. The plugin provides many features to simplify the use of Selenium with Rails. For example, it does the following:

  1. Creates test suites automatically from tests that are located in the same directory. For example, storing a test in test/selenium/authentication/test_login.sel would automatically make the test (test_login.sel) belong to the authentication test suite. 
     
  2. Deploys Selenium to the test environment automatically. (Selenium is not deployed to the development or production environments by default.) 
     
  3. Allows you to write Selenium tests in ERB, Selenese, or RSelenese, rather than just HTML.
     
  4. Lets you place the Selenium files in a directory other than /public. Selenium can be located in /vendor/selenium or the RubyGems repository. 
     
  5. Allows for the use of fixtures in Selenium tests and clearing sessions. Fixtures are run by accessing the URL /selenium/setup from acceptance tests.


blog comments powered by Disqus
RUBY-ON-RAILS ARTICLES

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials