Home arrow Ruby-on-Rails arrow Page 3 - Recording Acceptance Tests
RUBY-ON-RAILS

Recording Acceptance Tests


In this conclusion to a three-part article series on acceptance testing with Ruby on Rails, you'll learn how to use the Selenium IDE and how (and why) to record the results of your acceptance tests. This article 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 / 2
July 30, 2010
TABLE OF CONTENTS:
  1. · Recording Acceptance Tests
  2. · Recording the View Forum Acceptance Test
  3. · Recording the Post to Forum Acceptance Test
  4. · Recording the Show Post Acceptance Test
  5. · Recording the Reply to Post Acceptance Test

print this article
SEARCH DEVARTICLES

Recording Acceptance Tests - Recording the Post to Forum Acceptance Test
(Page 3 of 5 )

In the acceptance test for the Post to Forum user story, which describes how a post is created, we want to verify that posting to the forum works and that the post is shown on the forum main page.

Record the acceptance test by following these steps: 

  1. Select File -> New Test from the Selenium IDE menu. Verify that Selenium IDE is recording, by checking that the red record button is activated. 
     
  2. Open http://localhost:3000/forum in your browser. Line 1 should now contain an open command. You should also see the posts that were created by the previous test case. 
     
  3. Click the New post link at the top of the page. You should see a clickAndWait command inserted at line 2.   
  4. On the new post page, type a name (for example, Luke Rhinehart) in the Name field.
       
  5. In the Subject field, type a post subject (for example, The Dice Man).  
  6. In the Body field, type a message (for example, Roll the die!).   
  7. Click the Post button. You should be redirected to the main page of the forum, where you should see the post.   
  8. Select the text ("The Dice Man by Luke Rhinehart" in our example).   
  9. Right-click the selected text and select verifyTextPresent The Dice Man by Luke Rhinehart from the pop-up menu.   
  10. Save the recorded test as test/selenium/forum/02_post_to_forum.sel (by selecting File -> Save Test from the Selenium IDE menu).

Run the test by clicking the run button in Selenium IDE. You should see the test succeed (all rows are green), as shown in Figure 11-9. 


Figure 11-9.  The Post to Forum acceptance test in Selenium IDE

If you open 02_post_to_forum.sel in an editor, you should see something like the following:

|open|/forum||
|clickAndWait|link=New post||
|type|post[name]|Luke Rhinehart|
|type|post[subject]|The Dice Man|
|type|post[body]|Roll the die!| |clickAndWait|commit|| |verifyTextPresent|The Dice Man by Luke Rhinehart||

Now test that the View Forum and Post to Forum acceptance tests work when both are run in succession by executing the following:

$ rake test:acceptance


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-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials