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
