On Thu, 30 Oct 2003 10:22 pm, Michal Maczka wrote: > There is a lot of examples of such unit tests. > E.g. I18N service which reads messages from XML files. To test it you > need to provide few XML files > and to place them somewhere. Mock object are not really helpful here.
I am not sure I agree. You can always manually construct the XML via something like String text = "<i18n><entry key=\"foo\" value=\"blah\"/></i18n/>" Reader r = new StringReader( text ); InputSource source = new InputSource( r ); myParser.parse( source ); For another example (of processing java source files) where a similar strategy is used check out http://spice.sourceforge.net/metaclass/xref-test/org/realityforge/metaclass/tools/compiler/ClassDescriptorCompilerTestCase.html#311 Notice how the unit test never needs to read any resources or anything like that. I used to be skeptical about this approach but I am a convert now ;) If you want some good examples of this approach the http://spice.sourceforge.net/metaclass/xref-test shows some decent examples (I am biased as I was the author) but another great source of test patterns to imitate is the qdox.codehaus.org project. > Some application might need configuration files - e.g. configuration of > logging mechanism (specially log4j needs it). I am sure you could always manually configure it by either passing in properties or xml representations of config or by directly manipulating the LogManager class or whatever. -- Cheers, Peter Donald ----------------------------------------------- "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." -Albert Einstein ----------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]