WebUnit

yuichi TAKAHASHI(Japan Brainware Trust,Inc.)
$Id: index-en.html,v 1.20 2001/10/19 07:38:38 yuichi Exp $


Table of Contents


1. 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.


2. 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.


3. Download and Install

Download webunit-200YMMDD-*.tar.gz from http://xp.jbt.co.jp/download/webunit/, and, extract it to some directory, then, do ``ruby install.rb''.


4. Example

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

-----

5. Copying

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.


6. Bug Report

mailto:yuichi@jbt.co.jp


7. Changes

20011002-alpha -> now

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