Update of /cvsroot/jwebunit/jWebUnit/doc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28831/doc

Modified Files:
        fit-quickstart.html 
Added Files:
        fit-api.html 
Log Message:
jw: some fit documentation

Index: fit-quickstart.html
===================================================================
RCS file: /cvsroot/jwebunit/jWebUnit/doc/fit-quickstart.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** fit-quickstart.html 31 Mar 2003 04:15:06 -0000      1.2
--- fit-quickstart.html 19 Nov 2004 16:07:20 -0000      1.3
***************
*** 2,6 ****
  <html>
  <head>
!     <title>jWebUnit - Quick Start</title>
      <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
      <link title="Default" href="css/jwebunit.css" type="text/css" 
rel="stylesheet">
--- 2,6 ----
  <html>
  <head>
!     <title>jWebFit - Quick Start</title>
      <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
      <link title="Default" href="css/jwebunit.css" type="text/css" 
rel="stylesheet">
***************
*** 11,15 ****
      <tr>
          <td valign="top" style="width: 100px; white-space: nowrap;"><br></td>
!         <td valign="top" ><h1 style="text-align: center;">jWebUnit Quick 
Start</h1></td>
      </tr>
      <tr>
--- 11,15 ----
      <tr>
          <td valign="top" style="width: 100px; white-space: nowrap;"><br></td>
!         <td valign="top" ><h1 style="text-align: center;">jWebFit Quick 
Start</h1></td>
      </tr>
      <tr>
***************
*** 24,96 ****
              <br>
              <a href="http://httpunit.sourceforge.net/";>HttpUnit</a><br>
!             <a href="http://www.junit.org";>Junit</a><br>
              <br>
          </td>
          <td valign="top">
  <!-- Begin Main -->
! The QuickStart contains sample code and guidance to get you started with 
jWebUnit.  To see all
! of the methods available, consult the a <a href="api/index.html">Javadocs</a> 
- particularly
! the WebTester class.  The QuickStart covers the following topics:<p>
  <table class="default" id="topicsTable">
! <tr><td><a href="#navigating">Navigating Your Web Application</a></td></tr>
! <tr><td><a href="#forms">Working With Forms</a></td></tr>
! <tr><td><a href="#framesAndWindows">Working With Frames and 
Windows</a></td></tr>
! <tr><td><a href="#validation">Validating Page Content</a></td></tr>
! <tr><td><a href="#tableValidation">Validating Table Content</a></td></tr>
! <tr><td><a href="#elementValidation">Using Element IDs to Validate 
Content</a></td></tr>
! <tr><td><a href="#properties">Using Property Files to Validate 
Content</a></td></tr>
! <tr><td><a name="createTestCase">
  </table>
  
! <a name="navigating">
! <h2>Navigating Your Web Application</h2>
  <p>
! Navigation is a two step process.  First, point the FIT test to your 
application, then access a particular resource. 
! Let's say that your app is running on <tt>http://myserver:8080/myapp</tt>, 
and the resource you want to access is info.html, then the following table will 
take your test there.
  </p>
  
- <div class="fittable">
  <table border="1">
! <tr><td colspan="2">net.sourceforge.jwebunit.fit.WebFixture</td></tr>
! <tr><td>base url</td><td>http://myserver:8080/myapp</td></tr>
! <tr><td>begin   </td><td>info.html</td></tr>
  </table>
- </div>
  
  <p>
! You can also navigate through links either by text contained in the link or 
by the link's
! id:</p>
! &lt;a id="addLink" href="/addPage"&gt;Add Widget&lt;/a&gt;<br>
! &lt;a id="editlink" href="/editPage"&gt;Edit Widget&lt;/a&gt;<br>
! <br>
! <div class="fittable">
  <table border="1">
! <tr><td colspan="3">net.sourceforge.jwebunit.fit.WebFixture</td></tr>
! <tr><td>base url</td><td colspan="2">http://myserver:8080/myapp</td></tr>
! <tr><td>begin   </td><td colspan="2">info.html</td></tr>
! <tr><td> press</td><td> link id </td><td>addLink</td></tr>
! <tr><td>press</td><td> link</td><td>Edit Widget</td></tr>
  </table>
! </div>
  
! <br>
! <a name="forms">
! <h2>Working With Forms</h2>
! You can navigate to a page with a form, check for the presence and correct 
default values of form elements,
! set form element values, and submit the form.
  
- <div class="fittable">
  <table border="1">
  <tr><td colspan="4">net.sourceforge.jwebunit.fit.WebFixture</td></tr>
  <tr><td>base url</td><td colspan="3">http://myserver:8080/myapp</td></tr>
! <tr><td>begin   </td><td>info.html</td><td colspan="2"></td></tr>
! <tr><td>check</td><td> form present </td><td 
colspan="2">expectedFormName</td></tr>
! <tr><td>check</td><td> element present </td><td colspan="2">field1</td></tr>
! <tr><td>check</td><td> form element 
</td><td>field2</td><td>field2_defaultValue</td></tr>
! <tr><td>enter</td><td> field1 </td><td colspan="2">value1</td></tr>
! <tr><td>enter</td><td> fieldN </td><td colspan="2">valueN</td></tr>
! <tr><td>press</td><td>submit</td><td colspan="2"></td></tr>
  </table>
! </div>
  
  <p>You can also check for the presence of submit buttons on the form and 
submit with a specific button.</p>
--- 24,182 ----
              <br>
              <a href="http://httpunit.sourceforge.net/";>HttpUnit</a><br>
!             <a href="http://fit.c2.com";>Fit</a><br>
              <br>
          </td>
          <td valign="top">
  <!-- Begin Main -->
! <p>jWebFit is the clever name for extensions to jWebUnit which allow tests to 
be written with Ward Cunningham's fit framework
! as opposed to java / JUnit.  If you are unfamiliar with fit, give yourself a 
basic idea of how it works by visiting the
! <a href="http://fit.c2.com";>fit site</a>.
! </p>  
! <p>There are basically two ways to approach using fit with jWebUnit: use the 
fit fixtures provided by
! us (primarily the WebFixture class), or write your own fit fixtures that 
interact with the jWebUnit WebTester class.  You can get
! off the ground quickly with the former approach, but the latter approach with 
custom fixtures allows you much greater control and 
! ability to define your own testing syntax.
! </p>
! The QuickStart covers the following topics:<p>
  <table class="default" id="topicsTable">
! <tr><td><a href="#webfixture">Basic WebFixture Example</a></td></tr>
! <tr><td><a href="#tablefixture">Validating table contents with the 
TableFixture</a></td></tr>
! <tr><td><a href="#optiondisplay">Validating select options with OptionDisplay 
fixture</a></td></tr>
! <tr><td><a href="#customfixture">Writing custom fixtures</a></td></tr>
! <tr><td><a href="#running">Running the tests</a></td></tr>
! <tr><td><a href="#fitnesse">Integrating with Fitnesse</a></td></tr>
  </table>
  
! <a name="webfixture">
! <h2>Using WebFixture</h2>
  <p>
! The key class that adapts jWebUnit to fit is the WebFixture class.  It is a 
fit action fixture that delegates commands and
! checks to an instance of a jWebUnit WebTester.  The following example 
demonstrates use of WebFixture; see <a href="fit-api.html">the list
! of checks and commands</a> for more.
  </p>
  
  <table border="1">
! <tr><td colspan="4"> net.sourceforge.jwebunit.fit.WebFixture</td></tr>
! <tr><td>base url</td><td colspan="3">http://myserver:8080/myapp</td></tr>
! <tr><td>begin</td><td colspan="3">info.html</td></tr>
! <tr><td>check</td><td>form present</td><td 
colspan="2">expectedFormName</td></tr>
! 
! <tr><td> check   </td><td> form element </td><td> color                      
</td><td bgcolor="#cfffcf"> red </td></tr>
! <tr><td> enter   </td><td> color        </td><td colspan="2"> pink            
           </td></tr>
! <tr><td> check   </td><td> form element </td><td> color                      
</td><td bgcolor="#cfffcf"> pink </td></tr>
! 
! <tr><td> press   </td><td colspan="3"> submit       </td></tr>
! <tr><td> check   </td><td> title        </td><td colspan="2" 
bgcolor="#cfffcf"> Color Page                 </td></tr>
! <tr><td> check   </td><td> text present </td><td colspan="2" 
bgcolor="#cfffcf"> Your chosen color was pink </td></tr>
  </table>
  
+ <a name="tablefixture">
+ <h2>Using TableFixture</h2>
  <p>
! The TableFixture and TableRow classes provides a way to validate the contents 
of simple data tables.  The rows and columns of the
! TableFixture act as the expected contents against the targeted application 
table, and fit reports the results of the
! comparison when the fixture is run.  Missing and surplus rows are reported as 
well as the results of column comparisons.
! </p>
! 
  <table border="1">
! <tr><td 
colspan="4">net.sourceforge.jwebunit.fit.PersonalInfoTableFixture</td></tr>
! <tr><td>name</td><td>citizenship</td><td>state</td><td>sex</td></tr>
! <tr><td bgcolor="#cfffcf">John Doe</td><td bgcolor="#cfffcf">a 
citizen</td><td bgcolor="#cfffcf">Tennessee</td><td 
bgcolor="#cfffcf">male</td></tr>
! <tr><td bgcolor="#cfffcf">Jane Doe</td><td bgcolor="#cfffcf">a 
citizen</td><td bgcolor="#cfffcf">Tennessee</td><td 
bgcolor="#cfffcf">female</td></tr>
! <tr><td bgcolor="#cfffcf">Pat Doe</td><td bgcolor="#cfffcf">not a 
citizen</td><td bgcolor="#cfffcf">North Carolina</td><td 
bgcolor="#cfffcf">female</td></tr>
  </table>
! <p>
! To perform the above validation, both the TableFixture and TableRow classes 
were extended to provide both the id of the
! table to be validated and the mapping of columns to field names:
! </p>
! <pre>
! public class PersonalInfoTableFixture extends TableFixture {
  
!     protected String getSourceTableSummaryOrId() {
!         return "personalInfoTable";
!     }
! 
!     public Class getTargetClass() {
!         return PersonalInfoRow.class;
!     }
! }
! </pre>
! 
! <pre>
! public class PersonalInfoRow extends TableRow {
! 
!     public String name;
!     public String citizenship;
!     public String state;
!     public String sex;
! 
!     public PersonalInfoRow(String[] rowCells) {
!         super(rowCells);
!         this.name = rowCells[0];
!         this.citizenship = rowCells[1];
!         this.state = rowCells[2];
!         this.sex = rowCells[3];
!     }
! }
! </pre>
! 
! <a name="optiondisplay">
! <h2>Using OptionDisplay</h2>
! <p>
! The OptionDisplay fixture can be used to validate the contents of an html 
select list.  Either the
! human readable lable or the value or both can be validated:
! </p>
! <p>
! <table border="1">
! <tr><td>net.sourceforge.jwebunit.fit.OptionDisplay</td></tr>
! <tr><td>state</td></tr>
! <tr><td>label</td></tr>
! <tr><td bgcolor="#cfffcf">Tennessee</td></tr>
! <tr><td bgcolor="#cfffcf">Georgia</td></tr>
! </table>
! </p>
! <p>
! <table border="1">
! <tr><td colspan="2">net.sourceforge.jwebunit.fit.OptionDisplay</td></tr>
! <tr><td colspan="2">state</td></tr>
! <tr><td>label</td><td>value</td></tr>
! <tr><td bgcolor="#cfffcf">Tennessee</td><td bgcolor="#cfffcf">TN</td></tr>
! <tr><td bgcolor="#cfffcf">Georgia</td><td bgcolor="#cfffcf">GA</td></tr>
! </table>
! </p>
! <p>
! The second row contains the name of the select list, while the third row 
indicates what is being validated (label, 
! value, or both).  Subsequent rows are the expected options.
! </p>
! 
! 
! <a name="customfixture">
! <h2>Using Custom Fixtures</h2>
! One of the core ideas behind fit is to create easily readable tests.  Using 
the WebFixture can be a little
! awkward in this regard.  Writing a custom fixture that extends WebFixture or 
simply uses a WebTester instance itself can
! provide a greater control over syntax, allowing for more understandable tests.
! 
! <p>
! For an example, consider a web page that collects a comment from a user.  It 
provides a form for entering
! the user's name, email address, selecting their country from a list, and a 
text field for the comment itself.  After
! submitting, the user is taken to a page that thanks them for their comment.  
A test using the WebFixture is 
! shown below:
! </p>
  
  <table border="1">
  <tr><td colspan="4">net.sourceforge.jwebunit.fit.WebFixture</td></tr>
  <tr><td>base url</td><td colspan="3">http://myserver:8080/myapp</td></tr>
! <tr><td>begin</td><td colspan="3">comment.html</td></tr>
! <tr><td>enter</td><td>customerName</td><td colspan="2">John Doe</td></tr>
! <tr><td>enter</td><td>emailAddress</td><td colspan="2">[EMAIL 
PROTECTED]</td></tr>
! <tr><td>select</td><td>country</td><td colspan="2">USA</td></tr>
! <tr><td>enter</td><td>comment</td><td colspan="2">Test Comment</td></tr>
! <tr><td>press</td><td colspan="3">submit</td></tr>
! <tr><td>press</td><td> form element </td><td> color                      
</td><td bgcolor="#cfffcf"> pink </td></tr>
! 
! <tr><td> check   </td><td> title        </td><td colspan="2" 
bgcolor="#cfffcf"> Color Page                 </td></tr>
! <tr><td> check   </td><td> text present </td><td colspan="2" 
bgcolor="#cfffcf"> Your chosen color was pink </td></tr>
  </table>
! 
  
  <p>You can also check for the presence of submit buttons on the form and 
submit with a specific button.</p>

--- NEW FILE: fit-api.html ---
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>jWebFit - Table of Commands and Checks</title>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
    <link title="Default" href="css/jwebunit.css" type="text/css" 
rel="stylesheet">
</head>
<body class="default">
<table cellpadding="4" cellspacing="2" border="0" class="default">
    <tbody>
    <tr>
        <td valign="top" style="width: 100px; white-space: nowrap;"><br></td>
        <td valign="top" ><h1 style="text-align: center;">jWebFit Commands and 
Checks</h1></td>
    </tr>
    <tr>
        <td valign="top" style="white-space: nowrap;">
            <a href="index.html">Home</a><br>
            <a href="installation.html">Installation</a><br>
            Quick Start<br>
            <a href="api/index.html">Javadoc</a><br>
            <br>
            <a href="http://sourceforge.net/projects/jwebunit/";>Project 
Page</a><br>
            <a 
href="http://sourceforge.net/projects/jwebunit/files";>Download</a><br>
            <br>
            <a href="http://httpunit.sourceforge.net/";>HttpUnit</a><br>
            <a href="http://www.junit.org";>Junit</a><br>
            <br>
        </td>
        <td valign="top">
<!-- Begin Main -->
This page outlines the sytax for interacting with jWebUnit through fit using 
the WebFixture class.<p>
<table class="default" id="topicsTable">
<tr><td><a href="#navigating">Navigational commands</a></td></tr>
<tr><td><a href="#formentry">Form interaction / submission 
commands</a></td></tr>
<tr><td><a href="#assertions">Assertions (Checks)</a></td></tr>
<tr><td><a href="#debugging">Debugging</a></td></tr>
</table>

<a name="navigating">
<h2>Navigation Commands</h2>
<p>
jWebUnit methods to navigate through a web application are explicitly supported 
on the WebFixture class:
</p>
<table class="fittable" border="1">
<tr><td>base url</td><td colspan=2>http://myserver:8080/myapp</td><td 
rowspan="8"></td><td bgcolor="#FFFFFF">Set the base url for the tested 
application.</td></tr>
<tr><td>begin</td><td colspan=2>info.html</td><td bgcolor="#FFFFFF">Begin a 
series of interactions at a given page in the application.</td></tr>
<tr><td>press</td><td>link</td><td>Text of Link</td><td bgcolor="#FFFFFF">Press 
a link that contains the indicated text.</td></tr>
<tr><td>press</td><td>link id</td><td>linkId</td><td bgcolor="#FFFFFF">Press a 
link with the indicated Id.</td></tr>
<tr><td>window</td><td colspan=2>windowIdOrTitle</td><td 
bgcolor="#FFFFFF">Begin interacting with indicated window.</td></tr>
<tr><td colspan=3>base window</td><td bgcolor="#FFFFFF">Return to the base 
window.</td></tr>
<tr><td>page</td><td colspan=2>page.html</td><td bgcolor="#FFFFFF">Begin 
interaction with indicated page.</td></tr>
<tr><td>frame</td><td colspan=2>frameName</td><td bgcolor="#FFFFFF">Begin 
interaction with indicated frame.</td></tr>
</table>

<a name="formentry">
<h2>Form Entry and Submission Commands</h2>
<p>
Form interaction methods are also explicitly supported in the WebFixture class:
</p>

<table class="fittable" border="1">
<tr><td>form</td><td colspan=2>formName</td><td rowspan="8"></td><td 
bgcolor="#FFFFFF">Begin working with named form - not needed if only one form 
on page.</td></tr>
<tr><td>enter</td><td>formElementName</td><td>Value to enter</td><td 
bgcolor="#FFFFFF">Provide a value for a form element (use for radio groups and 
text boxes).</td></tr>
<tr><td>select</td><td>option</td><td>displayedOptionValue</td><td 
bgcolor="#FFFFFF">Choose indicated select box option (by text displayed to 
user).</td></tr>
<tr><td>select</td><td>checkbox</td><td>checkBoxName</td><td 
bgcolor="#FFFFFF">Select indicated checkbox (no support for specific value in 
WebFixture yet).</td></tr>
<tr><td>deselect</td><td>checkbox</td><td>checkBoxName</td><td 
bgcolor="#FFFFFF">Deselect indicated checkbox.</td></tr>
<tr><td>press</td><td colspan=2>submit</td><td bgcolor="#FFFFFF">Press default 
submit button.</td></tr>
<tr><td>press</td><td>submit</td><td>buttonName</td><td bgcolor="#FFFFFF">Press 
submit button with indicated name.</td></tr>
</table>

<a name="assertions">
<h2>Assertions / Checks</h2>
<p>
The WebFixture class allows access to all of the assertions on the jWebUnit 
WebTester class through use of reflection.
The fit syntax is: | check | methodName | argument1 | argument2 | etc.  The 
method name can be expressed in camel case,
or you can put spaces between the words and the fixture will figure out the 
camel case.  
</p>
<p>
Examples:
<table class="fittable" border="1">
<tr><td>check</td><td>text present</td><td>expected text</td><td 
rowspan="2"></td><td bgcolor="#FFFFFF">Deterimine if text contained in exected 
response.</td></tr>
<tr><td>check</td><td>form element present</td><td>formElementName</td><td 
bgcolor="#FFFFFF">Deterimine if expected form element is present.</td></tr>
</table>
</p>
<p>
Assertion methods on WebTester that end with "equals", like 
assertFormElementEquals, have a short-hand syntax that allows the
"equals" to be left off.  These methods are shown below.
</p>
<p>
<table class="fittable" border="1">
<tr><td>check</td><td>form element</td><td>formElementName</td><td>expected 
value</td><td rowspan="2"></td><td bgcolor="#FFFFFF">Deterimine if text 
contained in exected response.</td></tr>
<tr><td>check</td><td>title</td><td colspan="2">expected title</td><td 
bgcolor="#FFFFFF">Deterimine if expected form element is present.</td></tr>
<tr><td>check</td><td>option</td><td>selectBoxName</td><td>expectedValue</td><td
 rowspan="2"></td><td bgcolor="#FFFFFF">Deterimine if the indicated option of a 
drop down list is selected.</td></tr>
</table>
</p>

<p>
A few methods are shorthanded for convenience as well:
</p>
<p>
<table class="fittable" border="1">
<tr><td>check</td><td>link</td><td>linkText</td><td rowspan="2"></td><td 
bgcolor="#FFFFFF">Maps to assertLinkPresentWithText(containedText).</td></tr>
<tr><td>check</td><td>link id</td><td>linkId</td><td bgcolor="#FFFFFF">Maps to 
assertLinkPresent(id).</td></tr>
</table>
</p>
<a name="debugging">
<h2>Debugging</h2>
<p>
A common way to diagnose unexpected results in jWebUnit is to dump the content 
of the current response
in HttpUnitDialog.  You can do this from fit as well - the content will go to 
system.err.
</p>

<table class="fittable" border="1">
<tr><td>enter</td><td>dump response</td><td bgcolor="#FFFFFF">Write content of 
current response to system.err.</td></tr>
</table>

<!-- End Main -->
        </td>
    </tr>
    <tr>
        <td valign="top" colspan="3"><hr width="100%" size="2"></td>
    </tr>
    <tr>
        <td valign="top" colspan="2">
      <p><font size="-2"><var:publish>Hosted by: <a
 href="file:///D:/working/jwebunit/site/www.sourceforge.net"><img
 src="http://sourceforge.net/sflogo.php?group_id=61302&amp;type=1"; width="88"
 height="31" border="0" alt="SourceForge Logo" naturalsizeflag="0"
 align="top">                 </a></var:publish></font></p>
        </td>
    </tr>
    </tbody>
</table>
</body>
</html>



-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Jwebunit-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to