PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">


What's WebUnit

WebUnit is Ruby API for testing html/cgi without browser, and is idealy suited for automated unit testing of web sites when combined with a Ruby unit test framework such as RubyUnit. It was designed and implemented by Masaki Suketa.

I used HttpUnit with JUnit, however, I didn't like writing test in Java, when I write program in Ruby. Then, I made it.

Libraries Used

WebUnit uses these software follow. Now, these files of htmlrepair/htmlsplit and html-parser are included in WebUnit package, so, you don't have to install them. You have to install RubyUnit and NQXML, before using WebUnit.

Download and Install

Download webunit-20YYMMDD-*.tar.gz from <URL:>, and, extract it to some directory, then, do ruby install.rb.


Execute test/test_*.rb with test runner like runtest.rb, after make symbolic link cgi directory to accessable directory via httpd, with name "webunit".

% ln -s webunit/cgi $DOCUMENT_ROOT/tmp/webunit
% cp webunit/cgi/auth/.htpasswd /tmp
% URLBASE=http://localhost/tmp/ runtest.rb test_link.rb

require 'webunit/webunit'

# get start HTML page
url = 'test-1.html'
response = WebUnit::Response::get( url )

# test HTML page contents
assert_title( 'test-1', response )
assert_equals( 1, response.forms.size )

form = response.form

# test form of HTML page contents
assert_equals( 'ntext',     form.parameters[0].name )
assert_equals( 'npassword', form.parameters[1].name )

# execute CGI script, after setting parameters
form.parameters[0].value = "this is test"
form.parameters[1].value = '!@#$%'
response = form.submit

# test output from CGI script
assert_equals( 'result', response.title )
assert_equals( 1, response.links.size )
assert_equals( 'http://....', response.links[0] )

# read link
response = response.links[0].read


This Program is copyrighted free software by yuichi TAKAHASHI.

You can redistribute it and/or modify it under either the terms of the GPL (see COPYING file), or same as Ruby.

Bug Report



20020410-alpha -> 20030121

20020330-alpha -> 20020410-alpha

20011019-alpha -> 20020330-alpha

20011019-alpha -> 20011022-alpha

20011002-alpha -> 20011019-alpha

20010919-alpha -> 20011002-alpha

20010912-alpha -> 20010919-alpha

20010714-alpha -> 20010912-alpha

20010618-alpha -> 20010714-alpha

20010611-alpha -> 20010618-alpha

20010604-alpha -> 20010611-alpha

20010521-alpha -> 20010604-alpha

20010507-alpha -> 20010521-alpha

20010330-alpha -> 20010507-alpha

20010314-alpha -> 20010330-alpha

20010223-alpha -> 20010314-alpha

20010216-alpha -> 20010223-alpha

20010215-alpha -> 20010216-alpha