Home arrow Ruby-on-Rails arrow Page 4 - 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 Show Post Acceptance Test
(Page 4 of 5 )

Next, we'll create a test that verifies that the Show Post user story works as intended. You should now have the forum main page open in Firefox, which is where we left off in the previous section.

Like the other tests, the test case requires that we are on the page where the previous test ended. We'll use the assertLocation check to verify this. 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. Click the Source tab and type |assertLocation|/forum|| in the text area, as shown in Figure 11-10. Switch back to the previous view by clicking the Table tab.


    Figure 11-10.  The Source tab showing the acceptance test after step 2
  3. Click the second line in the table.
  4. Click the post that was created by the Post to Forum acceptance test (The Dice Man). You are now taken to the show post page.
  5. Select the text "The Dice Man," right-click it, and select verifyTextPresent The Dice Man from the pop-up menu.
  6. Select the text "Luke Rhinehart," right-click it, and select verifyTextPresent Luke Rhinehart from the pop-up menu.
  7. Right-click the Reply link and select assertTextLink link=Reply Reply from the pop-up menu. 
     
  8. Save the test as test/selenium/forum/03_show_post.sel (by selecting File -> Save Test from the Selenium IDE menu).

The file should now contain the following:

|assertLocation|/forum|| |clickAndWait|link=The Dice Man|| |verifyTextPresent|'The Dice Man'|| |assertText|link=Reply|Reply|

Verify that what you have done so far works by executing the acceptance tests once again:

$ rake test:acceptance

You should see the acceptance tests run without failures.


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