Support Requests item #989293, was opened at 2004-07-12 02:32
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=497983&aid=989293&group_id=61302
Category: None
Group: None
Status: Pending
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Refactoring JWebUnit tests
Initial Comment:
Hi
I have a web app that I'd like to test. I find my code
becoming too hard to maintain, each test case gets too
long with lots of code repeated across them. In an
effort to refactor the tests, I'm thinking of this
approach. Each "page" is a step required to complete a
"task". There's a tester for each page that knows how
to fill in its values and navigate back, forward,
cancel or complete the task. So a test case simply
creates a tester for the page, sets values, runs
assertions. Advancing to the next/previous page returns
the page tester object for that page.
What's the best way to do this?
Here is what I came up with so far. My PageTester
extends WebTestCase. The constructor of the Tester
inits the TestContext. The client of the PageTester,
say HomePageTest extends TestCase. In HomePageTest, I
might do
public void testSomething() {
HomePageTester tester = new HomePageTester();
tester.setValue();
SomeOtherPageTester otherPageTester = tester.next();
}
My problem is that the test can't make use of the
easier to use methods (setFormElementWithLabel...etc).
To use them, the tests need to extend WebTestCase or
use WebTester. In either case, i'll be faced with the
problem of keeping the Tester's web conversation and
the Test's web converstaion in sync. I'm just thinking
out loud and looking for feedback.
Thanks in advance
Srini
P.S. One other idea that came to mind is to have a
WebTester in the Tester. I was curious to know why
WebTester is tied to the HTTPUnitDialog. Why can't
there be a constructor for WebTester that takes a
HTTPUnitDialog? Also, I'm using JWebUnit 1.1.1.
Upgrading to 1.2 causes org.w3c.dom.DOMException:
NOT_SUPPORTED_ERR
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2004-09-17 18:09
Message:
Logged In: NO
Hi,
If you are looking separating common tasks shared across
different pages, easiest approach is, create a class which
extends WebTestCase. Define all the common tasks in there.
Then just extend that class instead of WebTestCase for your
tests.
/Rajesh
----------------------------------------------------------------------
Comment By: Jim Weaver (jimweaver)
Date: 2004-09-16 12:22
Message:
Logged In: YES
user_id=619947
I believe someone responsed to the refactoring aspect on the
user list - so setting this as pending. The
NOT_SUPPORTED_ERR using 1.2 sounds like a classpath issue, btw.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=497983&aid=989293&group_id=61302
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Jwebunit-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users