On Thursday, Nov 7, 2002, at 23:00 Europe/London, Mike Cannon-Brookes wrote:

Simon,

You can test your actions without going through the whole framework.

Something like:

ActionContext.setSession(session);
MyAction act = new MyAction();
act.setFoo("bar");
act.execute();

Should work fine?
That's precisely what I do at the moment, because it can be done out of the container and runs quickly. It also means that I can replace supporting classes with Mocks, so that I can make sure that things are working as I expect them to when something unexpected happens. For example, right now, it's very easy to simulate duplicate users in my app by simply setting up the mocks correctly:

public void testCreateUserCommandWithDuplicateUser() {
action.setCommand( "create" );
action.setUsername( "sms" );
edit.setupGetUsername( "sms" );
factory.setupExceptionCreateUser( new DuplicateUserException() );

String result = action.doCreate();

assertEquals( Action.ERROR, result );
}

lifted almost directly from my current tests. "action" is the Action being tested, and "edit" and "factory" are both mocks ("factory" returns the "edit" mock, which is configured in setUp())

I've not seen much testing code before, especially for webwork projects, so it would be handy to learn how the people most familiar and experienced with the framework do this sort of thing.

Regards,

Simon



-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to