tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Tapestry > Test
Date Mon, 20 Sep 2010 08:38:01 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/12/_/styles/combined.css?spaceKey=TAPESTRY&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/TAPESTRY/Test">Test</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~uli">Ulrich
Stärk</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h1><a name="Test-TapestryTestUtilities"></a>Tapestry Test Utilities</h1>

<p>This library is just a couple of base classes to make it easier to build integration
test suites around <a href="http://www.openqa.org/selenium/" class="external-link" rel="nofollow">Selenium</a>.</p>

<p>This library is currently based on Selenium 0.8.1.</p>

<p>The strategy is to start, in process, a Selenimum Server (which, in turn, starts
and manages a web browser), a Jetty instance (for the web browser to talk to), and a Selenium
client (which talks to the server).</p>

<p>The client is able to request URLs, fill in form data, click links, and make assertions
about output and behavior.</p>

<h1><a name="Test-UsageandConfiguration"></a>Usage and Configuration</h1>

<p>The core part of this library is a base class for you to extend your tests cases
from: <span class="error">&#91;AbstractIntegrationTestSuite|../apidocs/org/apache/tapestry5/test/AbstractIntegrationTestSuite.html&#93;</span>.</p>

<p>This class is responsible for starting an instance of Jetty to server your web application,
as well as a copy of Selenium Server. It also implements the <a href="http://release.openqa.org/selenium-remote-control/0.9.0/doc/java/"
class="external-link" rel="nofollow">Selenium</a> interface.</p>

<p>You must inform the suite about the location of your web application. The default
location is <tt>src/main/webapp</tt> (as this is the default directory for storing
a web application when building using Maven). This can be changed by provided a public constructor
for your test suite.</p>

<p>Here's an example from one of the Tapestry modules:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>package org.apache.tapestry5.spring;

import org.apache.tapestry5.test.AbstractIntegrationTestSuite;
import org.testng.annotations.Test;

public class TapestrySpringIntegrationTest extends AbstractIntegrationTestSuite
{
    public TapestrySpringIntegrationTest()
    {
        super("src/test/webapp");
    }
    
    @Test
    public void integration_test() throws Exception
    {
        open(BASE_URL);

        type("input", "paris in the springtime");
        clickAndWait("//input[@value='Convert']");

        assertFieldValue("input", "PARIS IN THE SPRINGTIME");
    }

    @Test
    public void access_to_spring_context() throws Exception
    {
        open(BASE_URL);

        assertTextPresent("[upcase]");
    }
}</pre>
</div></div>

<p>This is a very simple example, and demonstrates a mix of Selenium methods (such as
open() and type()) and methods added by the AbstractIntegrationTestSuite base class (clickAndWait()
and assertFieldValue()).</p>

<p>Of course, a real integration test would contain many methods, and may need to single
thread their execution, or even specify an execution order.</p>

<p>In addition, the AbstractIntegrationTestSuite base class extends the normal exception
reporting provided by Selenium; when a failure occurs inside Selenium server, a more detailed
message, including the current page's HTML source, is reported to System.err.</p>

    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="https://cwiki.apache.org/confluence/display/TAPESTRY/Test">View Online</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message