Vincent Massol wrote:
> 
> Hi Jari,
> 
> ----- Original Message -----
> > Assuming that Cactus is to be the place for server side testing tools,
> > either for in container or mock tests then:
> >
> > Ideas for later versions
> >
> > - help for server side testing of the struts framework, e.g. for testing
> > Actions, ActionMappings etc. How are they testing struts btw. ?
> 
> Yes, that's a good idea. I have thought about it already and I have 2 ideas
> :
> - provide some mock implementations objects to help unit test struts. We
> would put these mock objects in a package like
> org.apache.commons.cactus.extension.struts or something alike and users
> would be able to use them in their testXXX() methods,
> or
> - provide some factory helper classes that return *real* instances of struts
> objects (like ActionMapping, ...). In the current version of Cactus, if you
> want to unit test, say an Action that you have written, you would need to
> manually instanciate an ActionMapping, ActionForm, ... So you need to write
> about 10-15 lines of code to create these objects. The goal would be to
> replace this code by some helper classes that return these live objects. It
> seems Struts is well written and it would be easy to create real instances
> of objects and initialize them the way we want for the test. However, if it
> is not possible then we'll have to revert to option 1, i.e. provide mock
> objects which is also fine.
> 

I think the Mock versus in container discussions are going to run for a
while. Seems like both would be useful - then you can test against mock
implementations while developing, then run in container tests to make
sure what you expected was going to happen actually happened... :)
Running the same test in container helps you test that your container
configuration is correct, which is valuable.

<snip>
> > When testing something that takes some XML, say an Element, is there an
> > easy way of testing ? I have had problems with JUnit and using XML
> > trying to create XML documents.
> >
> 
> You mean creating a DOM structure prior to calling a method that accept an
> Element object for instance ? Yes, why not, we could put this in the util
> package.

That's exactly what I mean. It seems a real pain to have to write tests
where you get a DocumentBuilder, parse etc to be able to test a small
amount of functionality in a unit test. Doesn't seem to fit in with the
ethos of trying to keep unit tests simple. Do you know what any of the
other XP bods have done? (thinking of XTC members?).

Jari


--
Jari Worsley
Senior Programmer
Hyperlink Interactive Ltd

Reply via email to