I'm still very happy with my test code that does use the WW framework. I
haven't seen any performance problems (entire suite runs under 1s) but I
suppose my machine might have a little more oomph than yours. Though even on
my old PIII 600Mhz laptop the suite runs in 4seconds max. I like to treat my
testing of code as purely a blackbox, to the point where i don't even create
the actual object. So I guess in a way I'm not testing each method of my
code, but each instance (alias) in views.properties (I too actually use a
test_views.properties for unit tests). Here's what a typical test looks like
for me:

   public void testRemovePrimarySubjectLast() {
        params.put("subjectIds", new long[] {1, 2, 3, 4});
        params.put("primarySubjectId", new Long(4));
        params.put("subjectId", new Long(4));

        RemoveSubject remove = (RemoveSubject) runActionSuccess();
        long[] subjectIds = remove.getSubjectIds();
        long primarySubjectId = remove.getPrimarySubjectId();

        assertNotNull(subjectIds);
        assertEquals(3, primarySubjectId);
        assertEquals(3, subjectIds.length);
        assertEquals(1, subjectIds[0]);
        assertEquals(2, subjectIds[1]);
        assertEquals(3, subjectIds[2]);
    }

-Pat

----- Original Message -----
From: "Mike Cannon-Brookes" <[EMAIL PROTECTED]>
To: "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]>
Sent: Thursday, November 07, 2002 3:00 PM
Subject: Re: [OS-webwork] Unit testing Actions


> 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?
>
> Cheers,
> Mike
>
> On 8/11/02 12:01 AM, "Simon Stewart" ([EMAIL PROTECTED]) penned the words:
>
> > I'm curious to know how other people on the list unit test their
> > Actions. Patrick, at  least, uses his custom AbstractActionTest to run
> > the tests (ultimately) via the GenericDispatcher. Others, such as Joe
> > (according to his blog) prefer to treat their Actions as normal
> > classes, with methods that need to be tested after being setup in a
> > certain way.
> >
> > I can see the attractions of both ways: following one route, you can
> > rely on the framework being used in precisely the same way as it will
> > during deployment. The other way requires a certain amount of knowledge
> > of how the Action will be called, but allows one to pass in state and
> > supporting classes more easily (for example, Mocks to stub out database
> > access)
> >
> > After having a play with both, I'm tempted to fall to the side of
> > testing each of the methods in turn. This is partly because testing
> > within webwork slows my tests enough to be irksome on my relatively
> > humble machine, and partly because I want to test that each method
> > works as it should --- I can manipulate the tests (eg. causing an
> > IOException, or throwing a database exception) a lot more easily by
> > passing in state and running the method being tested directly than I
> > can by going through the entire framework. If I well off track here,
> > then it'd be nice to get some pointers from the experts....
> >
> > 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
>
>
>
> -------------------------------------------------------
> 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



-------------------------------------------------------
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