Automated Testing

May 10, 2008 10:32 by Danimal

Almost every day in the "Answers" section of LinkedIn asking about automated testing of a web page. This one is typical : "What is a good Open source / Free test automation acceptance and regression tool for dot net applications?".

My usual response is "We've had great success using Watir for automated testing in IE. It's built in Ruby, so there may be a bit of a learning curve. Still, there are excellent tools out there to record and build scripts."

Watir, short for "Web Application Testing in Ruby", is a free, open-source testing library for the Ruby language.  It's very easy to use, and extremely powerful.  The Watir engine automates an instance of Internet Explorer (or Firefox, if you use Firewatir),  and gives you easy access to the page content. It's a real lifesaver when dealing with testing multiple page forms.

A simple example in Watir to test my blog page:

require "watir"

# open the IE browser

ie = Watir::IE.new 

ie.goto "http://danimal.acsysinteractive.com"

if ie.text.include? "Musings on web development"  
puts "  Test Passed. Found the test string: 'Musings on web development"
else
puts "  Test Failed! Could not find: 'Musings on web development'." 
end 

Obviously, that's a basic example, but it's very easy to click buttons, follow links, and the like. However, for longer tests you don't really want to hand-write all of the Ruby code. That's where a script recorder is very useful. With a recorder such as Watir Recorder, you can simply browse a site in the application to record the script. Save it as a .rb file and you can run it over and over again.

Frequent testing of your GUI with Watir, and unit testing your business logic can go a long way toward quality code. If you're not using something like Watir, why not check it out?

Del.icio.usDigg It!DZone It!FurlNewsVineReddit

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Add comment


(Will show your Gravatar icon)  

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]