|
STAQS |
Software Testing and Quality Services |
Lessons Learned working with Ruby
NOTE: This page was added in April 2009. It is under construction.
Feedback welcome. Please just keep in mind that I know much needs to be
updated here. Thanks.
RUBY
1. Quick Overview
If you are interested in Ruby, there are many sites and resources available
to help you learn more. Some include:
- Wikipedia has a pretty good overview on the
Ruby programming language
- Try Ruby (in your
browser) is a very useful tool that helped me interactively figure out
how a number of commands work. If you have 15 minutes of free time,
run through the tutorial on this page.
- The first edition of
Programming Ruby (a.k.a. 'Pickaxe') is available online, and is
packaged with Ruby in a convenient CHM file (for Windows users).
- If you get serious about Ruby, you should pick up a newer edition of the
'Pickaxe' book at
the Pragmatic
Bookshelf
- If you are an experienced scripter or prefer to learn by doing, I
recommend Brian Marick's book "Everyday
Scripting with Ruby". It teaches you both what Ruby can do and
good programming practices at the same time.
- When in doubt, you can always check out the
comp.lang.ruby group for answers when you get stuck.
- Something a little different - check out
Why's
(Poignant) Guide to Ruby. (Chunky bacon!)
There are many, many other libraries, frameworks and add-ons to Ruby that
help it do just about anything. Just look around.
2. Ruby Scripts
Examples of Scripts that I've written include:
- Session-Based Test Management scripts - ported from Perl to Ruby - see
my SBTM Projects page for source code
- more coming soon..
3. Scripting Tips
Do you know the difference between single quotes and double quotes when
working with strings in Ruby scripts?
..coming soon..
WATIR
1. Quick Overview
Some helpful Watir resources include:
- Wikipedia has an entry on
Watir that
might answer a few of your questions
- The main community home is on
OpenQA.org - links to installation instructions,
tutorials, articles, latest development builds, bug tracking tool and
more.
- The main
Watir
General mailing list can now be found on Google Groups
- There are many blogs and articles out there related to Watir. It
really is the simple part of this whole setup, so I don't have much more to
add here.
2. Test Framework Components
The foundation of testing web apps with Watir is made up of 3 parts:
- Ruby is a powerful, easy-to-use
object-oriented scripting language that runs on all the popular operating
systems. Best of all, it's free!
- Watir (pronounced 'water', not
'wa-teer') is a Ruby library used to automate Internet Explorer. You
install this separately. It can be used to test all types of web
applications (ASP, .Net, JSP, PHP, Rails, etc.)
- Test/Unit
framework or library comes with Ruby. It provides: (1) the structure
for the test methods/cases, (2) the assertions (i.e. verification check
points), and (3) some built-in summary metrics on things like number of
tests performed/failed and length of time to complete.
Download the Ruby and Watir one-click installers from:
http://wtr.rubyforge.org/
The thing to note here is that many people test with Ruby all the time but
don't use Watir (i.e. using just 1 & 3 above), and you can use the Watir library
to talk to web apps without necessarily testing them. There's flexibility
in how those 3 elements above can be used together, separately, or interchanged
with other components. The above combination for the purpose of testing
web apps from a user's perspective is the purpose I'm interested in here.
Depending on your particular testing project's needs, you might also need to
use other Ruby libraries. For example, to help you read/write to Excel
spreadsheets, parse XML, or use an additional scripting framework - e.g. like
RSPEC.
Have a question? Think something is missing? Drop me a line to
let me know.
Contact me at:
paul [at] staqs [dot] c o m