Revision: 782
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=782&view=rev
Author: henryju
Date: 2008-12-10 20:01:18 +0000 (Wed, 10 Dec 2008)
Log Message:
-----------
issue 2404789: updating the quickstart documentation (some fixes, reverts and
improvements)
Modified Paths:
--------------
trunk/src/site/site.xml
trunk/src/site/xdoc/articles.xml
trunk/src/site/xdoc/index.xml
trunk/src/site/xdoc/quickstart.xml
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2008-12-08 02:29:07 UTC (rev 781)
+++ trunk/src/site/site.xml 2008-12-10 20:01:18 UTC (rev 782)
@@ -37,23 +37,23 @@
<item name="Quick start" href="quickstart.html"
collapse="true">
<item name="Creating a TestCase"
- href="#Creating a TestCase" />
+ href="#Creating_a_TestCase" />
<item name="Selecting a plugin"
- href="#Selecting the plugin you want to use" />
+ href="#Selecting_the_plugin_you_want_to_use" />
<item name="Site Navigation"
- href="#Navigating Your Web Application" />
+ href="#Navigating_Your_Web_Application" />
<item name="Working With Forms"
- href="#Working With Forms" />
+ href="#Working_With_Forms" />
<item name="Frames and Windows"
- href="#Working With Frames and Windows" />
+ href="#Working_With_Frames_and_Windows" />
<item name="Validating Page Content"
- href="#Validating Page Content" />
+ href="#Validating_Page_Content" />
<item name="Validating Table Content"
- href="#Validating Table Content" />
+ href="#Validating_Table_Content" />
<item name="Using Element IDs"
- href="#Using Element IDs to Validate Content" />
+ href="#Using_Element_IDs_to_Validate_Content" />
<item name="Using Property Files"
- href="#Using Property Files to Validate Content" />
+ href="#Using_Property_Files_to_Validate_Content" />
</item>
<item name="Articles" href="articles.html" />
<item name="FAQ" href="faq.html" />
Modified: trunk/src/site/xdoc/articles.xml
===================================================================
--- trunk/src/site/xdoc/articles.xml 2008-12-08 02:29:07 UTC (rev 781)
+++ trunk/src/site/xdoc/articles.xml 2008-12-10 20:01:18 UTC (rev 782)
@@ -10,7 +10,8 @@
<ul>
<li><a
href="http://www.brodwall.com/johannes/blog/2006/12/10/in-process-web-integration-tests-with-jetty-and-jwebunit/">In-process
Web Integration Tests with Jetty and JWebUnit</a></li>
- <li><a
href="http://www.brodwall.com/johannes/blog/2007/01/20/article-ready-for-edit-embedded-web-integration-testing-with-jetty/">Embedded
Web Integration Testing with Jetty</a></li>
+ <li><a
href="http://portletwork.blogspot.com/2007/08/testing-portlets-with-jetty-pluto-and.html">Testing
Portlets with Jetty, Pluto and JWebUnit</a></li>
+ <li><a
href="http://blog.ippon.fr/2008/11/14/testez-vos-applications-graphiques-web">Testez
vos applications graphiques web (FR)</a></li>
</ul>
</p>
Modified: trunk/src/site/xdoc/index.xml
===================================================================
--- trunk/src/site/xdoc/index.xml 2008-12-08 02:29:07 UTC (rev 781)
+++ trunk/src/site/xdoc/index.xml 2008-12-10 20:01:18 UTC (rev 782)
@@ -47,7 +47,8 @@
<source>
public class ExampleWebTestCase extends WebTestCase {
- public ExampleWebTestCase(String name) {
+ public void setUp() {
+ super.setUp();
setBaseUrl("http://localhost:8080/test");
}
Modified: trunk/src/site/xdoc/quickstart.xml
===================================================================
--- trunk/src/site/xdoc/quickstart.xml 2008-12-08 02:29:07 UTC (rev 781)
+++ trunk/src/site/xdoc/quickstart.xml 2008-12-10 20:01:18 UTC (rev 782)
@@ -13,26 +13,57 @@
</p>
<subsection name="Creating a TestCase">
<p>
- JWebUnit follows the JUnit principle for creating test cases through
inheritance. Simply
- inherit from WebTestCase and you can start writing test cases right
away.
+ JWebUnit uses two approaches for creating test cases: inheritance and
delegation. The simplest is
+ to inherit from WebTestCase rather than junit.framework.TestCase.
- <source>
+ <source>
+import net.sourceforge.jwebunit.junit.WebTestCase;
+
public class ExampleWebTestCase extends WebTestCase {
- public ExampleWebTestCase(String name) {
- setBaseUrl("http://localhost:8080/test");
- }
+
+ public void setUp() {
+ super.setUp();
+ setBaseUrl("http://localhost:8080/test");
+ }
- public void test1() {
- beginAt("/home");
- clickLink("login");
- assertTitleEquals("Login");
- setTextField("username", "test");
- setTextField("password", "test123");
- submit();
- assertTitleEquals("Welcome, test!");
- }
+ public void test1() {
+ beginAt("/home");
+ clickLink("login");
+ assertTitleEquals("Login");
+ setTextField("username", "test");
+ setTextField("password", "test123");
+ submit();
+ assertTitleEquals("Welcome, test!");
+ }
}
- </source>
+ </source>
+ An alternative is to include an instance of the WebTester class in your
TestCase and delegate navigation
+ and assertions to it. This is provided in case you need or prefer
delegation.
+
+ <source>
+import junit.framework.TestCase;
+import net.sourceforge.jwebunit.junit.WebTester;
+
+public class ExampleWebTestCase extends TestCase {
+ private WebTester tester;
+
+ public void setUp() {
+ super.setUp();
+ tester = new WebTester();
+ }
+
+ public void test1() {
+ tester.beginAt("/home");
+ tester.clickLink("login");
+ tester.assertTitleEquals("Login");
+ tester.setTextField("username", "test");
+ tester.setTextField("password", "test123");
+ tester.submit();
+ tester.assertTitleEquals("Welcome, test!");
+ }
+}
+ </source>
+In the following samples, inheritance will be used.
</p>
</subsection>
@@ -44,7 +75,8 @@
import net.sourceforge.jwebunit.util.TestingEngineRegistry;
public class ExampleWebTestCase extends WebTestCase {
- public ExampleWebTestCase(String name) {
+ public void setUp() {
+ super.setUp();
setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
<i>// use HtmlUnit</i>
setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_SELENIUM);
<i>// use Selenium</i>
}
@@ -64,6 +96,7 @@
<source>
public void setUp() throws Exception {
+ super.setUp();
setBaseUrl("http://myserver:8080/myapp");
}
</source>
@@ -300,6 +333,7 @@
</p>
<source>
public void setUp() throws Exception {
+ super.setUp();
getTestContext().setbaseUrl("http://myserver:8080/myapp");
getTestContext().setResourceBundleName("ApplicationResources");
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
JWebUnit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development