I agree, your task solution seems like the way too go.
This is a delagation pattern similair to the WebTester object that is
delegated from WebTestCase.

Also, I would highly recommend doing the following as well.

Creating a base class for your company wide test case classes.

This is our hierarchy.

WebTestCase
+---SnccWebTestCase
    +---Appication1TestCase
    +---Application2TestCase

Also, consider using a parent / child type of pattern.
> public void testFoo() {
>     CreateFooTask createNewFoo = new CreateFooTask(getDialog(), "Foo",
"Bar");
>     SearchFooTask searchForFoo = new SearchFooTask(getDialog(), "F%");
>     createNewFoo.execute();
>     searchForFoo.execute();
> }

--JwebUnitTask  (holds local attribute to the dialog instance.
  +---CreateFooTask
  +---SearchFooTask

HTH.....

Nick


> -----Original Message-----
> From: Martijn Dashorst [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 16, 2004 12:03 PM
> To: Srinivasan Ranganathan
> Cc: [EMAIL PROTECTED]
> Subject: Re: [Jwebunit-development] Refactoring tests
> 
> 
> After reading your message again, I would say your 'Task' solution is 
> the right way to go.
> 
> You could do the following:
> 
> public void testFoo() {
>     CreateFooTask createNewFoo = new CreateFooTask("Foo", "Bar");
>     SearchFooTask searchForFoo = new SearchFooTask("F%");
>     createNewFoo.execute(getDialog());
>     searchForFoo.execute(getDialog());
> }
> 
> Passing in the dialog as a parameter for the execute actions would 
> enable you to maintain the session between tasks. I would 
> advise against 
> sharing the session between tests.
> 
> Martijn
> 
> Srinivasan Ranganathan wrote:
> 
> > 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.
> >
> > One other way I thought of is to add a WebTester constructor that 
> > takes a HTTPUnigDialog that store the WebTester in the 
> Tester class to 
> > hold the conversation state. But JWebUnit 1.1.1 (which Im using or 
> > 1.2) don't have such a constructor.
> >
> > Thanks in advance
> > Srini
> >
> >
> > P.S. Im curious to know why WebTester is tied in to the 
> > HTTPUnitDialog. i.e. why can't a WebTester be created with 
> a different 
> > HTTPUnitDialog than the one constructed in beginAt()? Also, why is 
> > setFormElementWithLabel protected?
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email sponsored by Black Hat Briefings & Training.
> > Attend Black Hat Briefings & Training, Las Vegas July 24-29 
> - digital 
> > self defense, top technical experts, no vendor pitches, unmatched 
> > networking opportunities. Visit www.blackhat.com
> > _______________________________________________
> > Jwebunit-development mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jwebunit-development
> >
> >
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by BEA Weblogic Workshop
> FREE Java Enterprise J2EE developer tools!
> Get your free copy of BEA WebLogic Workshop 8.1 today.
> http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
> _______________________________________________
> Jwebunit-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jwebunit-development
> 


- - - - - - 
This e-mail message is intended only for the use of the individual or entity
identified in the alias address of this message and may contain confidential
and privileged information. Any unauthorized review, use, disclosure or
distribution of this e-mail message is strictly prohibited. If you have
received this e-mail message in error, please notify the sender immediately
by reply e-mail and delete this message from your system. Thank you.


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
Jwebunit-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to