You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by cm...@apache.org on 2003/05/06 18:11:58 UTC
cvs commit: jakarta-cactus/documentation/docs/xdocs/integration index.xml howto_runner.xml
cmlenz 2003/05/06 09:11:58
Added: documentation/docs/xdocs/integration index.xml
Removed: documentation/docs/xdocs/integration howto_runner.xml
Log:
Rename to index.xml
Revision Changes Path
1.1 jakarta-cactus/documentation/docs/xdocs/integration/index.xml
Index: index.xml
===================================================================
<?xml version="1.0"?>
<document id="howto_runner">
<properties>
<title>TestRunner Howto</title>
<authors>
<author name="Vincent Massol" email="vmassol@apache.org"/>
</authors>
</properties>
<body>
<section title="Starting Cactus tests">
<p>
The Cactus tests are started using a JUnit Test Runner. There are
several configurations for executing these test runners:
</p>
<ul>
<li>
<jump anchor="from_ant">From Ant</jump>, by using the
<code><junit></code> task
</li>
<li>
<jump anchor="from_command_line">From the java command line</jump>,
calling the <code>main()</code> method of a Test Runner.
</li>
<li>
<jump anchor="from_ide">From an IDE</jump> or any tool providing a
JUnit integration plugin.
</li>
<li>
<jump anchor="from_browser">From a browser</jump>, by using the
Cactus Servlet Test Runner, which is a special JUnit Test Runner.
</li>
</ul>
</section>
<anchor id="from_ant"/>
<section title="Running Cactus tests from Ant">
<p>
Refer to the documentation about the Cactus
<link href="site:integration_ant">Ant Integration</link>.
</p>
</section>
<anchor id="from_command_line"/>
<section title="Running Cactus tests from the command line">
<p>
You need to set up your classpath in the same way as when you run
Cactus tests from Ant. However, you start the test with the following
command line (this is an example using the Swing UI TestRunner found
in the junit jar):
</p>
<p>
<code>junit.swingui.TestRunner.main [test case class]</code>
</p>
</section>
<anchor id="from_ide"/>
<section title="Running Cactus tests from an IDE">
<p>
Refer to the <link href="site:howto_ide">IDE Howto</link>.
</p>
</section>
<anchor id="from_browser"/>
<section title="Running Cactus tests from a browser">
<note>
This section only applies for Cactus 1.4 and greater.
</note>
<section title="Step 1: Setting up the classpath">
<p>
In order to run Cactus tests from a browser you need to have a webapp
containing your classes to test and your test classes. In addition,
both Cactus client side and server side jar classes must be able to be
loaded from your webapp (i.e located in your <code>WEB-INF/lib</code>
directory or in a location available through your container Context
class loader (refer to your container documentation).
</p>
<note>
Refer to the <link href="site:howto_classpath">Classpath Howto</link>
guide for the exact list of jars.
</note>
</section>
<section title="Step 2: Mapping the Cactus Servlet Test Runner">
<p>
Then, in addition to the Cactus redirectors that you have mapped in
your <code>web.xml</code> (see the
<link href="site:howto_config">Configuration howto</link>), you also
need to map the Cactus Servlet Test Runner, as follows:
</p>
<source><![CDATA[
[...]
<servlet>
<servlet-name>ServletTestRunner</servlet-name>
<servlet-class>
org.apache.cactus.server.runner.ServletTestRunner
</servlet-class>
</servlet>
[...]
<servlet-mapping>
<servlet-name>ServletTestRunner</servlet-name>
<url-pattern>/ServletTestRunner</url-pattern>
</servlet-mapping>
[...]
]]></source>
</section>
<section title="Step 3: Executing the tests">
<p>
Open a browser and type <code>http://server:port/mywebapp/ServletTestRunner?suite=mytestcase</code>
where:
</p>
<ul>
<li>
<code>server:port</code> is the name of your server machine and
port on which your container is running
</li>
<li>
<code>mywebapp</code> is the name of your webapp (usually the name
of your war file)
</li>
<li>
<code>mytestcase</code> is the fully qualified name (i.e. with
packages) of your <code>TestCase</code> class containing a
<code>suite()</code> method listing all the tests, in standard
JUnit fashion.
</li>
</ul>
<p>
Here is an example of what you will get:
</p>
<figure src="images/servlettestrunner_xml.jpg" alt="XML output of ServletTestRunner"/>
<note>
If you see a blank page, click on the View source option of your
browser. It means your browser doesn't know how to display XML data.
</note>
<p>
Ok, that's nice ... But what if I want HTML instead of XML? Don't
worry there is a solution. Grab the following
<link href="site:code_junit_noframes">stylesheet</link>
used to format JUnitReport Ant task results and drop it in your
webapp and name it <code>junit-noframes.xsl</code> (in the root
directory for example). Then, open a browser and type
<code>http://server:port/mywebapp/ServletTestRunner?suite=mytestcase&xsl=junit-noframes.xsl</code>.
You should see the following:
</p>
<figure src="images/servlettestrunner_html.jpg" alt="HTML output of ServletTestRunner"/>
<note>
This will work with Internet Explorer as the XSL transformation is
performed on the client side (i.e by the browser). I'm not sure
about other browsers.
</note>
</section>
<section title="Enabling Server-Side XSLT Transformations">
<p>
In the previous section, the XSLT transformation was performed on the
client. This requires a browser capable of doing XSLT transformations
in a standards-compliant manner, and requires adding the location of
the stylesheet as a request parameter.
</p>
<p>
Since Cactus 1.5, the ServletTestRunner can also perform the
transformation on the server-side. To enable that feature, make sure
that a JAXP compliant XSLT processor (such as
<link href="ext:xalanj">Xalan</link>) is available to the
web-application.
</p>
<p>
In addition, the location of the XSLT stylesheet needs to specified as
initialization parameter of the ServletTestRunner. For example:
</p>
<source><![CDATA[
[...]
<servlet>
<servlet-name>ServletTestRunner</servlet-name>
<servlet-class>
org.apache.cactus.server.runner.ServletTestRunner
</servlet-class>
<init-param>
<param-name>xsl-stylesheet</param-name>
<param-value>styles/cactus-report.xsl</param-value>
</init-param>
</servlet>
[...]
]]></source>
<p>
The specified path is relative to the root of the web-application. Of
course, the stylesheet needs to exist at that location. In contrast to
client-side transformations, the stylesheet may be placed somewhere
inside the <code>WEB-INF</code> directory, because clients do not need
to access it directly.
</p>
<p>
If all of the above is correctly set up, you can enable the actual
transformation by including a <code>transform</code> parameter with
the request (the value of the parameter does not matter). For example
</p>
<source><![CDATA[
http://server:port/mywebapp/ServletTestRunner?suite=mytestcase&transform=yes
]]></source>
<note>
The stylesheet specified as initialization parameter is loaded when
the ServletTestRunner gets initialized. Changes to the stylesheet will
not get picked up until the web-application is reloaded.
</note>
</section>
</section>
</body>
</document>
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org