Re: WOUnitTest pattern?
Re: WOUnitTest pattern?
- Subject: Re: WOUnitTest pattern?
- From: shaun <email@hidden>
- Date: Sun, 14 May 2006 01:44:10 +0930
Hi, Wolfram, Anjo,
On Sat, 2006-05-13 at 16:54 +0200, Anjo Krank wrote:
> OTTOMH, either move the actual methods to test elsewhere ie, don't do
> nextPage.setValue(context().stringFormValueForKey("foo")) but instead
> create a method that takes all needed info as parameters and test
> this, or (preferably) create a request with the URL parameters you
> want and create the DA manually, then call the methods you want to test.
Or, use composition rather than sticking all the functional code inside
the direct action method or class. eg)
public WOActionResults myAction(){
String a,b,c;
a = formValueForKey("a");
b = formValueForKey("b");
c = formValueForKey("c");
LogicObject lo = LogicObject.newInstance(a,b,c);
lo.myAction();
CustomPage p = (CustomPate) lo.ok() ?
pageWithName("CustomPageOK") :
pageWithName("CustomPageNotOk");
p.setLogicObject(lo);
return (WOActionResults)p;
}
Now you simply test the LogicObject's functionality not the DA.
regards,
- shaun
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden